From a5520872cc0a2f48fc45a040fdaf6c723bde3eb2 Mon Sep 17 00:00:00 2001 From: okxint Date: Sat, 1 Aug 2026 15:38:18 +0530 Subject: [PATCH] fix(react-router): prevent unstable_sentryVitePluginOptions spread from overwriting sourcemaps --- .../react-router/src/vite/makeCustomSentryVitePlugins.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts index b2d41378db33..196ea04728e0 100644 --- a/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts +++ b/packages/react-router/src/vite/makeCustomSentryVitePlugins.ts @@ -19,6 +19,11 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil release, } = options; + // Destructure keys that are merged explicitly below so the trailing spread + // cannot overwrite them with the user's raw value. + const { sourcemaps: userSourcemaps, ...restUnstableVitePluginOptions } = + unstable_sentryVitePluginOptions ?? {}; + const sentryVitePlugins = sentryVitePlugin({ applicationKey, authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN, @@ -45,9 +50,9 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil // will be handled in buildEnd hook sourcemaps: { disable: true, - ...unstable_sentryVitePluginOptions?.sourcemaps, + ...userSourcemaps, }, - ...unstable_sentryVitePluginOptions, + ...restUnstableVitePluginOptions, }) as Plugin[]; return sentryVitePlugins;