Skip to content
Open
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
9 changes: 5 additions & 4 deletions packages/react-router/src/vite/makeCustomSentryVitePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,34 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
} = options;

const sentryVitePlugins = sentryVitePlugin({
...unstable_sentryVitePluginOptions,
authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
bundleSizeOptimizations,
debug: debug ?? false,
org: org ?? process.env.SENTRY_ORG,
project: project ?? process.env.SENTRY_PROJECT,
telemetry: telemetry ?? true,
_metaOptions: {
...unstable_sentryVitePluginOptions?._metaOptions,
telemetry: {
...unstable_sentryVitePluginOptions?._metaOptions?.telemetry,
metaFramework: 'react-router',
},
...unstable_sentryVitePluginOptions?._metaOptions,
},
reactComponentAnnotation: {
...unstable_sentryVitePluginOptions?.reactComponentAnnotation,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unstable reactComponentAnnotation values always overridden by undefined

Low Severity

The reactComponentAnnotation section spreads unstable_sentryVitePluginOptions?.reactComponentAnnotation first, but then enabled: reactComponentAnnotation?.enabled ?? undefined explicitly sets enabled to undefined when the user doesn't provide it, overriding any unstable fallback value. The ?? undefined is a no-op. This is inconsistent with the release pattern, which uses ...release and naturally preserves unstable values when the main option isn't provided. Using ...reactComponentAnnotation instead of the explicit property assignments would be consistent.

Additional Locations (1)
Fix in Cursor Fix in Web

enabled: reactComponentAnnotation?.enabled ?? undefined,
ignoredComponents: reactComponentAnnotation?.ignoredComponents ?? undefined,
...unstable_sentryVitePluginOptions?.reactComponentAnnotation,
},
release: {
...unstable_sentryVitePluginOptions?.release,
...release,
},
// will be handled in buildEnd hook
sourcemaps: {
disable: true,
...unstable_sentryVitePluginOptions?.sourcemaps,
disable: true,
},
...unstable_sentryVitePluginOptions,
}) as Plugin[];

return sentryVitePlugins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('makeCustomSentryVitePlugins', () => {
);
});

it('should allow overriding sourcemaps via unstable_sentryVitePluginOptions', async () => {
it('should merge sourcemaps options from unstable_sentryVitePluginOptions', async () => {
await makeCustomSentryVitePlugins({
unstable_sentryVitePluginOptions: {
sourcemaps: {
Expand All @@ -75,12 +75,12 @@ describe('makeCustomSentryVitePlugins', () => {
},
});

// unstable_sentryVitePluginOptions is spread last, so it fully overrides sourcemaps
expect(sentryVitePlugin).toHaveBeenCalledWith(
expect.objectContaining({
sourcemaps: {
sourcemaps: expect.objectContaining({
disable: true,
assets: ['dist/**'],
},
}),
}),
);
});
Expand Down
Loading