Skip to content

Commit 1c13825

Browse files
committed
fix: ensure we only delete nitro's sourcemaps
1 parent 52626ee commit 1c13825

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/nitro/src/sourceMaps.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function handleSourceMapUpload(
3939
sentryEnabledSourcemaps?: boolean,
4040
): Promise<void> {
4141
const outputDir = nitro.options.output.serverDir;
42-
const pluginOptions = getPluginOptions(options, sentryEnabledSourcemaps);
42+
const pluginOptions = getPluginOptions(options, sentryEnabledSourcemaps, outputDir);
4343

4444
const sentryBuildPluginManager = createSentryBuildPluginManager(pluginOptions, {
4545
buildTool: 'nitro',
@@ -75,7 +75,11 @@ function normalizePath(path: string): string {
7575
export function getPluginOptions(
7676
options?: SentryNitroOptions,
7777
sentryEnabledSourcemaps?: boolean,
78+
outputDir?: string,
7879
): BundlerPluginOptions {
80+
const defaultFilesToDelete =
81+
sentryEnabledSourcemaps && outputDir ? [`${outputDir.replace(/\\/g, '/')}/**/*.map`] : undefined;
82+
7983
return {
8084
org: options?.org ?? process.env.SENTRY_ORG,
8185
project: options?.project ?? process.env.SENTRY_PROJECT,
@@ -90,8 +94,7 @@ export function getPluginOptions(
9094
disable: options?.sourcemaps?.disable,
9195
assets: options?.sourcemaps?.assets,
9296
ignore: options?.sourcemaps?.ignore,
93-
filesToDeleteAfterUpload:
94-
options?.sourcemaps?.filesToDeleteAfterUpload ?? (sentryEnabledSourcemaps ? ['**/*.map'] : undefined),
97+
filesToDeleteAfterUpload: options?.sourcemaps?.filesToDeleteAfterUpload ?? defaultFilesToDelete,
9598
rewriteSources: options?.sourcemaps?.rewriteSources ?? ((source: string) => normalizePath(source)),
9699
},
97100
release: options?.release,

packages/nitro/test/sourceMaps.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ describe('getPluginOptions', () => {
2020
});
2121

2222
it('returns default options when no options are provided', () => {
23-
const options = getPluginOptions(undefined, true);
23+
const options = getPluginOptions(undefined, true, '/project/.output/server');
2424

2525
expect(options).toEqual(
2626
expect.objectContaining({
2727
telemetry: true,
2828
debug: false,
2929
silent: false,
3030
sourcemaps: expect.objectContaining({
31-
filesToDeleteAfterUpload: ['**/*.map'],
31+
filesToDeleteAfterUpload: ['/project/.output/server/**/*.map'],
3232
rewriteSources: expect.any(Function),
3333
}),
3434
_metaOptions: expect.objectContaining({

0 commit comments

Comments
 (0)