Skip to content

Commit 25e2ec0

Browse files
logaretmclaude
andcommitted
fix(nitro): Respect user-provided rewriteSources option
The `rewriteSources` option was hardcoded to `normalizePath`, silently discarding any custom function provided by the user. Now falls back to `normalizePath` only when the user doesn't provide their own function, matching the behavior of other meta-framework SDKs (Nuxt, Next.js). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 568fbdc commit 25e2ec0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/nitro/src/sourceMaps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function getPluginOptions(options?: SentryNitroOptions): BundlerPluginOpt
7777
assets: options?.sourcemaps?.assets,
7878
ignore: options?.sourcemaps?.ignore,
7979
filesToDeleteAfterUpload: options?.sourcemaps?.filesToDeleteAfterUpload ?? ['**/*.map'],
80-
rewriteSources: (source: string) => normalizePath(source),
80+
rewriteSources: options?.sourcemaps?.rewriteSources ?? ((source: string) => normalizePath(source)),
8181
},
8282
release: options?.release,
8383
bundleSizeOptimizations: options?.bundleSizeOptimizations,

packages/nitro/test/sourceMaps.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ describe('getPluginOptions', () => {
120120
expect(rewriteSources?.('src/index.ts', undefined)).toBe('src/index.ts');
121121
});
122122

123+
it('uses user-provided rewriteSources when given', () => {
124+
const customRewrite = (source: string) => `/custom/${source}`;
125+
const options = getPluginOptions({ sourcemaps: { rewriteSources: customRewrite } });
126+
127+
expect(options.sourcemaps?.rewriteSources?.('../../../src/index.ts', undefined)).toBe(
128+
'/custom/../../../src/index.ts',
129+
);
130+
});
131+
123132
it('always sets metaFramework to nitro', () => {
124133
const options = getPluginOptions();
125134

0 commit comments

Comments
 (0)