Skip to content

feat(nextjs): Add deleteSourcemapsAfterUpload option #12457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from 'fs';
import * as path from 'path';
import * as assert from 'assert/strict';

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

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

export {};
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ const nextConfig = {
};

module.exports = withSentryConfig(nextConfig, {
silent: true,
debug: true,
sourcemaps: {
deleteSourcemapsAfterUpload: true,
},
});
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@sentry/node": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0",
"@sentry/vite-plugin": "^2.18.0"
"@sentry/vite-plugin": "^2.19.0"
},
"devDependencies": {
"astro": "^3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0",
"@sentry/vercel-edge": "8.10.0",
"@sentry/webpack-plugin": "2.18.0",
"@sentry/webpack-plugin": "2.19.0",
"chalk": "3.0.0",
"resolve": "1.22.8",
"rollup": "3.29.4",
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ export type SentryBuildOptions = {
*
* Defaults to `false`.
*/
// TODO: Add this option
// deleteSourcemapsAfterUpload?: boolean;
deleteSourcemapsAfterUpload?: boolean;
};

/**
Expand Down
11 changes: 7 additions & 4 deletions packages/nextjs/src/config/webpackPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ export function getWebpackPluginOptions(
},
assets: sentryBuildOptions.sourcemaps?.assets ?? sourcemapUploadAssets,
ignore: sentryBuildOptions.sourcemaps?.ignore ?? sourcemapUploadIgnore,
// TODO: Add this functionality
// filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
// ? path.join(distDirAbsPath, '**', '*.js.map')
// : undefined,
filesToDeleteAfterUpload: sentryBuildOptions.sourcemaps?.deleteSourcemapsAfterUpload
? [
path.join(distDirAbsPath, '**', '*.js.map'),
path.join(distDirAbsPath, '**', '*.mjs.map'),
path.join(distDirAbsPath, '**', '*.cjs.map'),
]
: undefined,
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps,
},
release: {
Expand Down
2 changes: 1 addition & 1 deletion packages/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@sentry/svelte": "8.10.0",
"@sentry/types": "8.10.0",
"@sentry/utils": "8.10.0",
"@sentry/vite-plugin": "2.18.0",
"@sentry/vite-plugin": "2.19.0",
"magic-string": "0.30.7",
"magicast": "0.2.8",
"sorcery": "0.11.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('sentrySvelteKit()', () => {

expect(plugins).toBeInstanceOf(Array);
// 1 auto instrument plugin + 5 source maps plugins
expect(plugins).toHaveLength(6);
expect(plugins).toHaveLength(7);
});

it('returns the custom sentry source maps upload plugin, unmodified sourcemaps plugins and the auto-instrument plugin by default', async () => {
Expand All @@ -57,6 +57,7 @@ describe('sentrySvelteKit()', () => {
'sentry-vite-release-injection-plugin',
'sentry-debug-id-upload-plugin',
'sentry-vite-debug-id-injection-plugin',
'sentry-file-deletion-plugin',
// custom source maps plugin:
'sentry-upload-sveltekit-source-maps',
]);
Expand All @@ -83,7 +84,7 @@ describe('sentrySvelteKit()', () => {
it("doesn't return the auto instrument plugin if autoInstrument is `false`", async () => {
const plugins = await getSentrySvelteKitPlugins({ autoInstrument: false });
const pluginNames = plugins.map(plugin => plugin.name);
expect(plugins).toHaveLength(5);
expect(plugins).toHaveLength(6);
expect(pluginNames).not.toContain('sentry-upload-source-maps');
});

Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7191,10 +7191,10 @@
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.16.0.tgz#c831713b85516fb3f9da2985836ddf444dc634e6"
integrity sha512-+uy1qPkA5MSNgJ0L9ur/vNTydfdHwHnBX2RQ+0thsvkqf90fU788YjkkXwUiBBNuqNyI69JiOW6frixAWy7oUg==

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

"@sentry/[email protected]":
version "2.16.0"
Expand All @@ -7210,13 +7210,13 @@
magic-string "0.27.0"
unplugin "1.0.1"

"@sentry/bundler-plugin-core@2.18.0":
version "2.18.0"
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.18.0.tgz#2411cd934e9510c53a2e682497a74172485ac817"
integrity sha512-JvxVgsMFmDsU0Dgcx1CeFUC1scxOVSAOzOcE06qKAVm9BZzxHpI53iNfeMOXwVTUolD8LZVIfgOjkiXfwN/UPQ==
"@sentry/bundler-plugin-core@2.19.0":
version "2.19.0"
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.19.0.tgz#c21935ff5aea9daccfa4c9e0db405aecdec292f6"
integrity sha512-PGTwpue2k4HnLlCuvLeg+cILPWHJorzheNq8KVlXed8mpb8kxKeY9EWQFxBqPS+XyktOMAxZmCMZfKdnHNaJVQ==
dependencies:
"@babel/core" "^7.18.5"
"@sentry/babel-plugin-component-annotate" "2.18.0"
"@sentry/babel-plugin-component-annotate" "2.19.0"
"@sentry/cli" "^2.22.3"
dotenv "^16.3.1"
find-up "^5.0.0"
Expand Down Expand Up @@ -7278,12 +7278,12 @@
"@sentry/cli-win32-i686" "2.32.1"
"@sentry/cli-win32-x64" "2.32.1"

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

"@sentry/[email protected]":
Expand All @@ -7295,12 +7295,12 @@
unplugin "1.0.1"
uuid "^9.0.0"

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

Expand Down
Loading