Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ async function addSentryToEntryProperty(
// because it somehow tricks the file watcher into thinking that compilation itself is a file change, triggering an
// infinite recompiling loop. (This should be fine because we don't upload sourcemaps in dev in any case.)
if (isServer && !isDev) {
const rewriteFramesHelper = path.resolve(
fs.mkdtempSync(path.resolve(os.tmpdir(), 'sentry-')),
'rewriteFramesHelper.js',
);
const rewriteFramesHelper = path.resolve(os.tmpdir(), 'sentry-javascript', 'rewriteFramesHelper.js');
if (!fs.existsSync(path.dirname(rewriteFramesHelper))) {
fs.mkdirSync(path.dirname(rewriteFramesHelper));
}
fs.writeFileSync(rewriteFramesHelper, `global.__rewriteFramesDistDir__ = '${userNextConfig.distDir}';\n`);
// stick our helper file ahead of the user's config file so the value is in the global namespace *before*
// `Sentry.init()` is called
Expand Down
6 changes: 2 additions & 4 deletions packages/nextjs/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ describe('webpack config', () => {
incomingWebpackBuildContext: serverBuildContext,
});

const tempDir = mkdtempSyncSpy.mock.results[0].value;
const rewriteFramesHelper = path.join(tempDir, 'rewriteFramesHelper.js');
const rewriteFramesHelper = path.join(os.tmpdir(), 'sentry-javascript', 'rewriteFramesHelper.js');

expect(finalWebpackConfig.entry).toEqual(
expect.objectContaining({
Expand Down Expand Up @@ -515,8 +514,7 @@ describe('webpack config', () => {
incomingWebpackBuildContext: getBuildContext('server', userNextConfigDistDir),
});

const tempDir = mkdtempSyncSpy.mock.results[0].value;
const rewriteFramesHelper = path.join(tempDir, 'rewriteFramesHelper.js');
const rewriteFramesHelper = path.join(os.tmpdir(), 'sentry-javascript', 'rewriteFramesHelper.js');

expect(fs.existsSync(rewriteFramesHelper)).toBe(true);

Expand Down