Skip to content

Commit cd43cfd

Browse files
committed
fix getting of distDir value
1 parent 1f38137 commit cd43cfd

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

packages/nextjs/src/index.server.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,19 @@ function sdkAlreadyInitialized(): boolean {
4646
return !!hub.getClient();
4747
}
4848

49-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
50-
// console.log((global as any).__rewriteFramesDistDir__);
51-
// debugger;
52-
53-
// webpack will replace this placeholder at build time
54-
55-
// FIXME
56-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
57-
const SOURCEMAP_FILENAME_REGEX = new RegExp(escapeStringForRegex((global as any).__rewriteFramesDistDir__));
58-
59-
const defaultRewriteFramesIntegration = new RewriteFrames({
60-
iteratee: frame => {
61-
frame.filename = frame.filename?.replace(SOURCEMAP_FILENAME_REGEX, 'app:///_next/');
62-
return frame;
63-
},
64-
});
65-
66-
const defaultHttpTracingIntegration = new Integrations.Http({ tracing: true });
67-
6849
function addServerIntegrations(options: NextjsOptions): void {
50+
// This value is injected at build time, based on the output directory specified in the build config
51+
const buildDir = (global as typeof global & { __rewriteFramesDistDir__: string }).__rewriteFramesDistDir__;
52+
const SOURCEMAP_FILENAME_REGEX = new RegExp(escapeStringForRegex(buildDir));
53+
54+
const defaultRewriteFramesIntegration = new RewriteFrames({
55+
iteratee: frame => {
56+
frame.filename = frame.filename?.replace(SOURCEMAP_FILENAME_REGEX, 'app:///_next');
57+
return frame;
58+
},
59+
});
60+
const defaultHttpTracingIntegration = new Integrations.Http({ tracing: true });
61+
6962
if (options.integrations) {
7063
options.integrations = addIntegration(defaultRewriteFramesIntegration, options.integrations);
7164
} else {

0 commit comments

Comments
 (0)