Skip to content

Commit 250b6d3

Browse files
author
Luca Forstner
authored
feat(nextjs): Add deleteSourcemapsAfterUpload option (#12457)
1 parent 99c3ee5 commit 250b6d3

File tree

9 files changed

+45
-31
lines changed

9 files changed

+45
-31
lines changed

dev-packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from 'fs';
2+
import * as path from 'path';
23
import * as assert from 'assert/strict';
34

45
const packageJson = require('./package.json');
@@ -20,4 +21,11 @@ assert.match(buildStdout, /(λ|ƒ) \/server-component/);
2021
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[\.\.\.parameters\]/);
2122
assert.match(buildStdout, /(λ|ƒ) \/server-component\/parameter\/\[parameter\]/);
2223

24+
// Read the contents of the directory
25+
const files = fs.readdirSync(path.join(process.cwd(), '.next', 'server'));
26+
const mapFiles = files.filter(file => path.extname(file) === '.map');
27+
if (mapFiles.length > 0) {
28+
throw new Error('.map files found even though `sourcemaps.deleteSourcemapsAfterUpload` option is set!');
29+
}
30+
2331
export {};

dev-packages/e2e-tests/test-applications/nextjs-app-dir/next.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ const nextConfig = {
99
};
1010

1111
module.exports = withSentryConfig(nextConfig, {
12-
silent: true,
12+
debug: true,
13+
sourcemaps: {
14+
deleteSourcemapsAfterUpload: true,
15+
},
1316
});

packages/astro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@sentry/node": "8.10.0",
6767
"@sentry/types": "8.10.0",
6868
"@sentry/utils": "8.10.0",
69-
"@sentry/vite-plugin": "^2.18.0"
69+
"@sentry/vite-plugin": "^2.19.0"
7070
},
7171
"devDependencies": {
7272
"astro": "^3.5.0",

packages/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@sentry/types": "8.10.0",
7575
"@sentry/utils": "8.10.0",
7676
"@sentry/vercel-edge": "8.10.0",
77-
"@sentry/webpack-plugin": "2.18.0",
77+
"@sentry/webpack-plugin": "2.19.0",
7878
"chalk": "3.0.0",
7979
"resolve": "1.22.8",
8080
"rollup": "3.29.4",

packages/nextjs/src/config/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ export type SentryBuildOptions = {
153153
*
154154
* Defaults to `false`.
155155
*/
156-
// TODO: Add this option
157-
// deleteSourcemapsAfterUpload?: boolean;
156+
deleteSourcemapsAfterUpload?: boolean;
158157
};
159158

160159
/**

packages/nextjs/src/config/webpackPluginOptions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ export function getWebpackPluginOptions(
7474
},
7575
assets: sentryBuildOptions.sourcemaps?.assets ?? sourcemapUploadAssets,
7676
ignore: sentryBuildOptions.sourcemaps?.ignore ?? sourcemapUploadIgnore,
77-
// TODO: Add this functionality
78-
// filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
79-
// ? path.join(distDirAbsPath, '**', '*.js.map')
80-
// : undefined,
77+
filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
78+
? [
79+
path.join(distDirAbsPath, '**', '*.js.map'),
80+
path.join(distDirAbsPath, '**', '*.mjs.map'),
81+
path.join(distDirAbsPath, '**', '*.cjs.map'),
82+
]
83+
: undefined,
8184
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps,
8285
},
8386
release: {

packages/sveltekit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@sentry/svelte": "8.10.0",
4444
"@sentry/types": "8.10.0",
4545
"@sentry/utils": "8.10.0",
46-
"@sentry/vite-plugin": "2.18.0",
46+
"@sentry/vite-plugin": "2.19.0",
4747
"magic-string": "0.30.7",
4848
"magicast": "0.2.8",
4949
"sorcery": "0.11.0"

packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('sentrySvelteKit()', () => {
4343

4444
expect(plugins).toBeInstanceOf(Array);
4545
// 1 auto instrument plugin + 5 source maps plugins
46-
expect(plugins).toHaveLength(6);
46+
expect(plugins).toHaveLength(7);
4747
});
4848

4949
it('returns the custom sentry source maps upload plugin, unmodified sourcemaps plugins and the auto-instrument plugin by default', async () => {
@@ -57,6 +57,7 @@ describe('sentrySvelteKit()', () => {
5757
'sentry-vite-release-injection-plugin',
5858
'sentry-debug-id-upload-plugin',
5959
'sentry-vite-debug-id-injection-plugin',
60+
'sentry-file-deletion-plugin',
6061
// custom source maps plugin:
6162
'sentry-upload-sveltekit-source-maps',
6263
]);
@@ -83,7 +84,7 @@ describe('sentrySvelteKit()', () => {
8384
it("doesn't return the auto instrument plugin if autoInstrument is `false`", async () => {
8485
const plugins = await getSentrySvelteKitPlugins({ autoInstrument: false });
8586
const pluginNames = plugins.map(plugin => plugin.name);
86-
expect(plugins).toHaveLength(5);
87+
expect(plugins).toHaveLength(6);
8788
expect(pluginNames).not.toContain('sentry-upload-source-maps');
8889
});
8990

yarn.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7191,10 +7191,10 @@
71917191
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.16.0.tgz#c831713b85516fb3f9da2985836ddf444dc634e6"
71927192
integrity sha512-+uy1qPkA5MSNgJ0L9ur/vNTydfdHwHnBX2RQ+0thsvkqf90fU788YjkkXwUiBBNuqNyI69JiOW6frixAWy7oUg==
71937193

7194-
"@sentry/babel-plugin-component-annotate@2.18.0":
7195-
version "2.18.0"
7196-
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.18.0.tgz#3bee98f94945643b0762ceed1f6cca60db52bdbd"
7197-
integrity sha512-9L4RbhS3WNtc/SokIhc0dwgcvs78YSQPakZejsrIgnzLzCi8mS6PeT+BY0+QCtsXxjd1egM8hqcJeB0lukBkXA==
7194+
"@sentry/babel-plugin-component-annotate@2.19.0":
7195+
version "2.19.0"
7196+
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.19.0.tgz#70dcccb336bcec24148e1c9cd4e37724cebf5673"
7197+
integrity sha512-N2k8cMYu/7X6mzAH5j6bMeNcXQBJLL0lVAF63TDS57hUiT1v2uEqbeYFdH2CZBHb2LepLbMRXmvErIwy76FLTw==
71987198

71997199
72007200
version "2.16.0"
@@ -7210,13 +7210,13 @@
72107210
magic-string "0.27.0"
72117211
unplugin "1.0.1"
72127212

7213-
"@sentry/bundler-plugin-core@2.18.0":
7214-
version "2.18.0"
7215-
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.18.0.tgz#2411cd934e9510c53a2e682497a74172485ac817"
7216-
integrity sha512-JvxVgsMFmDsU0Dgcx1CeFUC1scxOVSAOzOcE06qKAVm9BZzxHpI53iNfeMOXwVTUolD8LZVIfgOjkiXfwN/UPQ==
7213+
"@sentry/bundler-plugin-core@2.19.0":
7214+
version "2.19.0"
7215+
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.19.0.tgz#c21935ff5aea9daccfa4c9e0db405aecdec292f6"
7216+
integrity sha512-PGTwpue2k4HnLlCuvLeg+cILPWHJorzheNq8KVlXed8mpb8kxKeY9EWQFxBqPS+XyktOMAxZmCMZfKdnHNaJVQ==
72177217
dependencies:
72187218
"@babel/core" "^7.18.5"
7219-
"@sentry/babel-plugin-component-annotate" "2.18.0"
7219+
"@sentry/babel-plugin-component-annotate" "2.19.0"
72207220
"@sentry/cli" "^2.22.3"
72217221
dotenv "^16.3.1"
72227222
find-up "^5.0.0"
@@ -7278,12 +7278,12 @@
72787278
"@sentry/cli-win32-i686" "2.32.1"
72797279
"@sentry/cli-win32-x64" "2.32.1"
72807280

7281-
"@sentry/vite-plugin@2.18.0", "@sentry/vite-plugin@^2.18.0":
7282-
version "2.18.0"
7283-
resolved "https://registry.yarnpkg.com/@sentry/vite-plugin/-/vite-plugin-2.18.0.tgz#f263f150b64591ac4db7f4e9a0b2cd8a03cada73"
7284-
integrity sha512-yY8QSvbMjRpG5pzN6lnW5guZhyTDSGeWwM9tDyT9ix/ShODy/eE6jErisBtlo50lFJuew7x79WXnVykvds4Ddg==
7281+
"@sentry/vite-plugin@2.19.0", "@sentry/vite-plugin@^2.19.0":
7282+
version "2.19.0"
7283+
resolved "https://registry.yarnpkg.com/@sentry/vite-plugin/-/vite-plugin-2.19.0.tgz#c7938fb13eee15036963b87d7b12c4fc851e488b"
7284+
integrity sha512-xmntz/bvRwhhU9q2thZas1vQQch9CLMyD8oCfYlNqN57t5XKhIs2dsCU/uS7HCnxIXuuUb/cZtIS7AXVg16fFA==
72857285
dependencies:
7286-
"@sentry/bundler-plugin-core" "2.18.0"
7286+
"@sentry/bundler-plugin-core" "2.19.0"
72877287
unplugin "1.0.1"
72887288

72897289
@@ -7295,12 +7295,12 @@
72957295
unplugin "1.0.1"
72967296
uuid "^9.0.0"
72977297

7298-
"@sentry/webpack-plugin@2.18.0":
7299-
version "2.18.0"
7300-
resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-2.18.0.tgz#f0955d28b1271e9a8b6a2927ab98b1688d7b03e1"
7301-
integrity sha512-iQ5OCvuoaIanbq4GRqj4Azay86mVpa64pP9Oi3EJpaURGZNLqwE7bWq9tkr1Dr7zBPBZN7QBmLD3OOeOSzbHuA==
7298+
"@sentry/webpack-plugin@2.19.0":
7299+
version "2.19.0"
7300+
resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-2.19.0.tgz#e2c011c15b9aed16916257a0eb883d0e1839d783"
7301+
integrity sha512-+TtwOAycYHX8uO/qGI81dFLW6opg4b/SZ/oJSC2K0sf8GUow6rv8RKcuzl4oPj3/QF1fuwsH7n8QCXm1XDMRdA==
73027302
dependencies:
7303-
"@sentry/bundler-plugin-core" "2.18.0"
7303+
"@sentry/bundler-plugin-core" "2.19.0"
73047304
unplugin "1.0.1"
73057305
uuid "^9.0.0"
73067306

0 commit comments

Comments
 (0)