diff --git a/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts b/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts index 37f5626e9ad0..aeb76ee19e32 100644 --- a/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts +++ b/dev-packages/e2e-tests/test-applications/astro-7-sourcemaps/assert-build.ts @@ -92,9 +92,6 @@ for (const outputDir of OUTPUT_DIRS) { } // The app does not set `build.sourcemap`, so the SDK enables hidden maps and must delete them after upload. -// TODO: The default `filesToDeleteAfterUpload` globs miss static output, which writes maps to `dist/_astro`. -if (!isStatic) { - assert.deepEqual(findSourceMapFiles({ outputDir: BUILD_OUTPUT }), [], `Expected no source maps in ${BUILD_OUTPUT}`); -} +assert.deepEqual(findSourceMapFiles({ outputDir: BUILD_OUTPUT }), [], `Expected no source maps in ${BUILD_OUTPUT}`); console.log('All sourcemap assertions passed!'); diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index 2d4ae0c152cb..b4e54545a8d3 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -71,8 +71,15 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { typeof sourcemaps?.filesToDeleteAfterUpload === 'undefined' && computedSourceMapSettings.previousUserSourceMapSetting === 'unset' ) { - // This also works for adapters, as the source maps are also copied to e.g. the .vercel folder - updatedFilesToDeleteAfterUpload = ['./dist/**/client/**/*.map', './dist/**/server/**/*.map']; + // This also works for adapters, as the source maps are also copied to e.g. the .vercel folder. + // Static output has no client folder and writes client assets to `/` instead. + // Astro removes the hidden `.prerender` folder itself, but we don't want to rely on that. + updatedFilesToDeleteAfterUpload = [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + `./dist/**/${config.build?.assets ?? '_astro'}/**/*.map`, + './dist/**/.prerender/**/*.map', + ]; debug && logger.info( diff --git a/packages/astro/test/integration/index.test.ts b/packages/astro/test/integration/index.test.ts index 19a272db17a7..54b199086c7c 100644 --- a/packages/astro/test/integration/index.test.ts +++ b/packages/astro/test/integration/index.test.ts @@ -112,7 +112,12 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['out/**/*', 'out/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -143,7 +148,12 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['dist/**/*', 'dist/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -182,7 +192,12 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['{.vercel,dist}/**/*', '{.vercel,dist}/**/.prerender/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', + ], }, _metaOptions: { telemetry: { @@ -221,7 +236,12 @@ describe('sentryAstro integration', () => { bundleSizeOptimizations: {}, sourcemaps: { assets: ['dist/server/**/*, dist/client/**/*'], - filesToDeleteAfterUpload: ['./dist/**/client/**/*.map', './dist/**/server/**/*.map'], + filesToDeleteAfterUpload: [ + './dist/**/client/**/*.map', + './dist/**/server/**/*.map', + './dist/**/_astro/**/*.map', + './dist/**/.prerender/**/*.map', + ], }, _metaOptions: { telemetry: {