Skip to content

Commit e326388

Browse files
nicohrubeccodex
andauthored
fix(v10/tanstackstart-react): Avoid duplicating Vite config arrays (#24935)
Backport of: #24929 ## Differences to the original PR - Keep the test's existing `@sentry/vite-plugin` import; v10 has not moved to `@sentry/bundler-plugins/vite`. - Omit `rolldownOptions` from the full expected config because v10 uses Vite 6, which does not add that Vite 8 alias. The SDK fix and regression coverage are otherwise unchanged. Co-authored-by: GPT-6 <codex@openai.com>
1 parent a681ae6 commit e326388

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎packages/tanstackstart-react/src/vite/sourceMaps.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ export function makeEnableSourceMapsVitePlugin(options: SentryTanstackStartOptio
100100
enforce: 'post',
101101
config(viteConfig) {
102102
return {
103-
...viteConfig,
104103
build: {
105-
...viteConfig.build,
106104
sourcemap: getUpdatedSourceMapSettings(viteConfig, options),
107105
},
108106
};

‎packages/tanstackstart-react/test/vite/sourceMaps.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// @vitest-environment node
12
import type { SentryVitePluginOptions } from '@sentry/vite-plugin';
23
import type { UserConfig } from 'vite';
4+
import { mergeConfig } from 'vite';
35
import { beforeEach, describe, expect, it, vi } from 'vitest';
46
import {
57
getUpdatedSourceMapSettings,
@@ -34,6 +36,33 @@ describe('makeEnableSourceMapsVitePlugin()', () => {
3436

3537
expect(sourceMapsConfigPlugins).toHaveLength(1);
3638
});
39+
40+
it.each([undefined, false, true, 'hidden', 'inline'] as const)(
41+
'preserves user config without duplicating arrays when sourcemap is %s',
42+
sourcemap => {
43+
const plugin = makeEnableSourceMapsVitePlugin({})[0]!;
44+
const configHook = plugin.config as (config: UserConfig) => UserConfig;
45+
const userConfig: UserConfig = {
46+
optimizeDeps: { include: ['react'] },
47+
build: {
48+
sourcemap,
49+
outDir: 'custom-dist',
50+
rollupOptions: { plugins: [{ name: 'asset-transform' }] },
51+
},
52+
};
53+
54+
const merged = mergeConfig(userConfig, configHook(userConfig));
55+
56+
expect(merged).toEqual({
57+
optimizeDeps: { include: ['react'] },
58+
build: {
59+
sourcemap: sourcemap ?? 'hidden',
60+
outDir: 'custom-dist',
61+
rollupOptions: { plugins: [{ name: 'asset-transform' }] },
62+
},
63+
});
64+
},
65+
);
3766
});
3867

3968
describe('makeAddSentryVitePlugin()', () => {

0 commit comments

Comments
 (0)