Skip to content

Commit 1f38137

Browse files
committed
cleanup
1 parent 4044067 commit 1f38137

File tree

1 file changed

+7
-34
lines changed

1 file changed

+7
-34
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,6 @@ export function constructWebpackConfigFunction(
8989
};
9090
}
9191

92-
// Support non-default output directories by making the output path (easy to get here at build-time) available to
93-
// the SDK's default `RewriteFrames` instance (which needs it at runtime).
94-
// const distDir = buildContext.config.distDir;
95-
newConfig.plugins = newConfig.plugins || [];
96-
97-
// const definePluginInstance = findWebpackPlugin(newConfig, 'DefinePlugin') as DefinePlugin;
98-
//
99-
// if (definePluginInstance) {
100-
// definePluginInstance.definitions['__rewriteFramesDistDir__'] = distDir;
101-
// } else {
102-
// newConfig.plugins.push(new DefinePlugin({ __rewriteFramesDistDir__: distDir }));
103-
// }
104-
105-
// if (buildContext.isServer) {
106-
// newConfig.plugins.push(
107-
// (new InjectPlugin(() => `global.__rewriteFramesDistDir__ = ${distDir};`, {
108-
// entryName: shouldAddSentryToEntryPoint, // Limit the injected code to only the entry w/ this name
109-
// entryOrder: ENTRY_ORDER.First, // Make the injected code be the first entry point
110-
// }) as unknown) as WebpackPluginInstance, // necessary because of a mismatch in @types/webpack versions between this plugin
111-
// );
112-
// }
113-
11492
// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
11593
const enableWebpackPlugin = buildContext.isServer
11694
? !userNextConfig.sentry?.disableServerWebpackPlugin
@@ -127,6 +105,7 @@ export function constructWebpackConfigFunction(
127105
newConfig.devtool = 'source-map';
128106
}
129107

108+
newConfig.plugins = newConfig.plugins || [];
130109
newConfig.plugins.push(
131110
new SentryWebpackPlugin(getWebpackPluginOptions(buildContext, userSentryWebpackPluginOptions)),
132111
);
@@ -168,30 +147,24 @@ async function addSentryToEntryProperty(
168147
// we need to turn the filename into a path so webpack can find it
169148
const filesToInject = [`./${userConfigFile}`];
170149

150+
// Support non-default output directories by making the output path (easy to get here at build-time) available to the
151+
// server SDK's default `RewriteFrames` instance (which needs it at runtime).
171152
if (buildContext.isServer) {
172153
const rewriteFramesHelper = path.resolve(
173154
fs.mkdtempSync(path.resolve(os.tmpdir(), 'sentry-')),
174155
'rewriteFramesHelper.js',
175156
);
176-
debugger;
177-
// Support non-default output directories by making the output path (easy to get here at build-time) available to
178-
// the server SDK's default `RewriteFrames` instance (which needs it at runtime).
179-
fs.writeFileSync(rewriteFramesHelper, `global.__rewriteFramesDistDir__ = '${buildContext.config.distDir}';\n`);
180-
filesToInject.push(rewriteFramesHelper);
157+
const buildDirAbsPath = path.resolve(buildContext.dir, buildContext.config.distDir);
158+
fs.writeFileSync(rewriteFramesHelper, `global.__rewriteFramesDistDir__ = '${buildDirAbsPath}';\n`);
159+
filesToInject.unshift(rewriteFramesHelper);
181160
}
182161

162+
//
183163
for (const entryPointName in newEntryProperty) {
184164
if (shouldAddSentryToEntryPoint(entryPointName)) {
185165
addFilesToExistingEntryPoint(newEntryProperty, entryPointName, filesToInject);
186166
}
187167
}
188-
//
189-
// if (buildContext.isServer) {
190-
// debugger;
191-
// rimraf(path.dirname(REWRITE_FRAMES_HELPER), err =>
192-
// logger.warn(`Could not remove ${REWRITE_FRAMES_HELPER}. Received error: ${err}`),
193-
// );
194-
// }
195168

196169
return newEntryProperty;
197170
}

0 commit comments

Comments
 (0)