Skip to content

Commit caedbb6

Browse files
cursoragentclaude
authored andcommitted
fix(react-router): preserve sourcemaps.disable override (#20042)
Ensure unstable vite plugin options don't overwrite sourcemaps.disable=true and update test expectations accordingly. Co-Authored-By: gpt-5.3-codex-high <noreply@anthropic.com>
1 parent 3815492 commit caedbb6

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/react-router/src/vite/makeCustomSentryVitePlugins.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
1919
} = options;
2020

2121
const sentryVitePlugins = sentryVitePlugin({
22+
...unstable_sentryVitePluginOptions,
2223
authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
2324
bundleSizeOptimizations,
2425
debug: debug ?? false,
@@ -27,25 +28,25 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
2728
telemetry: telemetry ?? true,
2829
_metaOptions: {
2930
telemetry: {
31+
...unstable_sentryVitePluginOptions?._metaOptions?.telemetry,
3032
metaFramework: 'react-router',
3133
},
3234
...unstable_sentryVitePluginOptions?._metaOptions,
3335
},
3436
reactComponentAnnotation: {
37+
...unstable_sentryVitePluginOptions?.reactComponentAnnotation,
3538
enabled: reactComponentAnnotation?.enabled ?? undefined,
3639
ignoredComponents: reactComponentAnnotation?.ignoredComponents ?? undefined,
37-
...unstable_sentryVitePluginOptions?.reactComponentAnnotation,
3840
},
3941
release: {
4042
...unstable_sentryVitePluginOptions?.release,
4143
...release,
4244
},
4345
// will be handled in buildEnd hook
4446
sourcemaps: {
45-
disable: true,
4647
...unstable_sentryVitePluginOptions?.sourcemaps,
48+
disable: true,
4749
},
48-
...unstable_sentryVitePluginOptions,
4950
}) as Plugin[];
5051

5152
return sentryVitePlugins;

packages/react-router/test/vite/makeCustomSentryVitePlugins.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('makeCustomSentryVitePlugins', () => {
6666
);
6767
});
6868

69-
it('should allow overriding sourcemaps via unstable_sentryVitePluginOptions', async () => {
69+
it('should merge sourcemaps options from unstable_sentryVitePluginOptions', async () => {
7070
await makeCustomSentryVitePlugins({
7171
unstable_sentryVitePluginOptions: {
7272
sourcemaps: {
@@ -75,12 +75,12 @@ describe('makeCustomSentryVitePlugins', () => {
7575
},
7676
});
7777

78-
// unstable_sentryVitePluginOptions is spread last, so it fully overrides sourcemaps
7978
expect(sentryVitePlugin).toHaveBeenCalledWith(
8079
expect.objectContaining({
81-
sourcemaps: {
80+
sourcemaps: expect.objectContaining({
81+
disable: true,
8282
assets: ['dist/**'],
83-
},
83+
}),
8484
}),
8585
);
8686
});

0 commit comments

Comments
 (0)