Skip to content

Commit 07075dd

Browse files
committed
fix value injection cry
1 parent a989527 commit 07075dd

File tree

3 files changed

+240
-71
lines changed

3 files changed

+240
-71
lines changed

packages/nextjs/src/config/turbopack/constructTurbopackConfig.ts

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,48 @@ export function constructTurbopackConfig({
2424
...userNextConfig.turbopack,
2525
};
2626

27-
if (routeManifest) {
28-
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, {
29-
matcher: '**/instrumentation-client.*',
30-
rule: {
31-
loaders: [
32-
{
33-
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
34-
options: {
35-
values: {
36-
_sentryRouteManifest: JSON.stringify(routeManifest),
37-
},
38-
},
27+
const isomorphicValues = {
28+
_sentryNextJsVersion: nextJsVersion || '',
29+
};
30+
31+
const clientValues = {
32+
...isomorphicValues,
33+
_sentryRouteManifest: JSON.stringify(routeManifest),
34+
};
35+
36+
const serverValues = {
37+
...isomorphicValues,
38+
};
39+
40+
// Client value injection
41+
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, {
42+
matcher: '**/instrumentation-client.*',
43+
rule: {
44+
loaders: [
45+
{
46+
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
47+
options: {
48+
...clientValues,
3949
},
40-
],
41-
},
42-
});
43-
}
50+
},
51+
],
52+
},
53+
});
4454

45-
if (nextJsVersion) {
46-
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, {
47-
matcher: '**/instrumentation.*',
48-
rule: {
49-
loaders: [
50-
{
51-
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
52-
options: {
53-
values: {
54-
_sentryNextJsVersion: nextJsVersion,
55-
},
56-
},
55+
// Server value injection
56+
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, {
57+
matcher: '**/instrumentation.*',
58+
rule: {
59+
loaders: [
60+
{
61+
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
62+
options: {
63+
...serverValues,
5764
},
58-
],
59-
},
60-
});
61-
}
65+
},
66+
],
67+
},
68+
});
6269

6370
return newConfig;
6471
}

packages/nextjs/src/config/webpack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,14 +728,14 @@ function addValueInjectionLoader({
728728
// Only inject if release creation is not explicitly disabled (to maintain build determinism)
729729
SENTRY_RELEASE: releaseToInject && !buildContext.dev ? { id: releaseToInject } : undefined,
730730
_sentryBasePath: buildContext.dev ? userNextConfig.basePath : undefined,
731+
_sentryNextJsVersion: nextJsVersion,
731732
};
732733

733734
const serverValues = {
734735
...isomorphicValues,
735736
// Make sure that if we have a windows path, the backslashes are interpreted as such (rather than as escape
736737
// characters)
737738
_sentryRewriteFramesDistDir: userNextConfig.distDir?.replace(/\\/g, '\\\\') || '.next',
738-
_sentryNextJsVersion: nextJsVersion || '0.0.0',
739739
};
740740

741741
const clientValues = {

0 commit comments

Comments
 (0)