Skip to content

Commit 6a1332e

Browse files
committed
disable hook for webpack and move flag to experimental
1 parent 4bf8eee commit 6a1332e

File tree

6 files changed

+55
-22
lines changed

6 files changed

+55
-22
lines changed

packages/nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@
7979
"@opentelemetry/api": "^1.9.0",
8080
"@opentelemetry/semantic-conventions": "^1.34.0",
8181
"@rollup/plugin-commonjs": "28.0.1",
82-
"@sentry/bundler-plugin-core": "^4.1.0",
82+
"@sentry/bundler-plugin-core": "^4.2.0",
8383
"@sentry-internal/browser-utils": "10.8.0",
8484
"@sentry/core": "10.8.0",
8585
"@sentry/node": "10.8.0",
8686
"@sentry/opentelemetry": "10.8.0",
8787
"@sentry/react": "10.8.0",
8888
"@sentry/vercel-edge": "10.8.0",
89-
"@sentry/webpack-plugin": "^4.1.1",
89+
"@sentry/webpack-plugin": "^4.2.0",
9090
"chalk": "3.0.0",
9191
"glob": "^11.0.3",
9292
"resolve": "1.22.8",

packages/nextjs/src/config/handleRunAfterProductionCompile.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export async function handleRunAfterProductionCompile(
1717
console.debug('[@sentry/nextjs] Running runAfterProductionCompile logic.');
1818
}
1919

20+
// We don't want to do anything for webpack at this point because the plugin already handles this
21+
// TODO: Actually implement this for webpack as well
22+
if (buildTool === 'webpack') {
23+
return;
24+
}
25+
2026
const { createSentryBuildPluginManager } =
2127
loadModule<{ createSentryBuildPluginManager: typeof createSentryBuildPluginManagerType }>(
2228
'@sentry/bundler-plugin-core',
@@ -57,6 +63,9 @@ export async function handleRunAfterProductionCompile(
5763
await sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal();
5864
await sentryBuildPluginManager.createRelease();
5965
await sentryBuildPluginManager.injectDebugIds(buildArtifacts);
60-
await sentryBuildPluginManager.uploadSourcemaps(buildArtifacts);
66+
await sentryBuildPluginManager.uploadSourcemaps(buildArtifacts, {
67+
// We don't want to prepare the artifacts because we injected debug ids manually before
68+
prepareArtifacts: true,
69+
});
6170
await sentryBuildPluginManager.deleteArtifacts();
6271
}

packages/nextjs/src/config/types.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,22 +501,22 @@ export type SentryBuildOptions = {
501501
*/
502502
disableSentryWebpackConfig?: boolean;
503503

504-
/**
505-
* When true (and Next.js >= 15), use the runAfterProductionCompile hook to consolidate sourcemap uploads
506-
* into a single operation after all webpack/turbopack builds complete, reducing build time.
507-
*
508-
* When false, use the traditional approach of uploading sourcemaps during each webpack build.
509-
*
510-
* @default false
511-
*/
512-
useRunAfterProductionCompileHook?: boolean;
513504

514505
/**
515506
* Contains a set of experimental flags that might change in future releases. These flags enable
516507
* features that are still in development and may be modified, renamed, or removed without notice.
517508
* Use with caution in production environments.
518-
*/
519-
_experimental?: Partial<{
509+
*/
510+
_experimental?: Partial<{
511+
/**
512+
* When true (and Next.js >= 15), use the runAfterProductionCompile hook to consolidate sourcemap uploads
513+
* into a single operation after all webpack/turbopack builds complete, reducing build time.
514+
*
515+
* When false, use the traditional approach of uploading sourcemaps during each webpack build.
516+
*
517+
* @default false
518+
*/
519+
useRunAfterProductionCompileHook?: boolean;
520520
thirdPartyOriginStackFrames: boolean;
521521
}>;
522522
};

packages/nextjs/src/config/webpackPluginOptions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ export function getWebpackPluginOptions(
7070
silent: sentryBuildOptions.silent,
7171
url: sentryBuildOptions.sentryUrl,
7272
sourcemaps: {
73-
// if the user has enabled the runAfterProductionCompileHook, we handle sourcemap uploads a later step
74-
disable: sentryBuildOptions.useRunAfterProductionCompileHook
75-
? 'disable-upload'
76-
: sentryBuildOptions.sourcemaps?.disable,
73+
disable: sentryBuildOptions.sourcemaps?.disable,
7774
rewriteSources(source) {
7875
if (source.startsWith('webpack://_N_E/')) {
7976
return source.replace('webpack://_N_E/', '');
@@ -98,8 +95,7 @@ export function getWebpackPluginOptions(
9895
...sentryBuildOptions.unstable_sentryWebpackPluginOptions?.sourcemaps,
9996
},
10097
release:
101-
// if the user has enabled the runAfterProductionCompileHook, we handle release creation a later step
102-
releaseName !== undefined && !sentryBuildOptions.useRunAfterProductionCompileHook
98+
releaseName !== undefined
10399
? {
104100
inject: false, // The webpack plugin's release injection breaks the `app` directory - we inject the release manually with the value injection loader instead.
105101
name: releaseName,

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function getFinalConfigObject(
294294
}
295295
}
296296

297-
if (userSentryOptions.useRunAfterProductionCompileHook === true && supportsProductionCompileHook()) {
297+
if (userSentryOptions?._experimental?.useRunAfterProductionCompileHook === true && supportsProductionCompileHook()) {
298298
if (incomingUserNextConfigObject?.compiler?.runAfterProductionCompile === undefined) {
299299
incomingUserNextConfigObject.compiler ??= {};
300300
incomingUserNextConfigObject.compiler.runAfterProductionCompile = async ({ distDir }) => {

yarn.lock

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6941,7 +6941,12 @@
69416941
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-4.1.1.tgz#371415afc602f6b2ba0987b51123bd34d1603193"
69426942
integrity sha512-HUpqrCK7zDVojTV6KL6BO9ZZiYrEYQqvYQrscyMsq04z+WCupXaH6YEliiNRvreR8DBJgdsG3lBRpebhUGmvfA==
69436943

6944-
"@sentry/[email protected]", "@sentry/bundler-plugin-core@^4.1.0":
6944+
6945+
version "4.2.0"
6946+
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-4.2.0.tgz#6c616e6d645f49f15f83b891ef42a795ba4dbb3f"
6947+
integrity sha512-GFpS3REqaHuyX4LCNqlneAQZIKyHb5ePiI1802n0fhtYjk68I1DTQ3PnbzYi50od/vAsTQVCknaS5F6tidNqTQ==
6948+
6949+
69456950
version "4.1.0"
69466951
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-4.1.0.tgz#c1b2f7a890a44e5ac5decc984a133aacf6147dd4"
69476952
integrity sha512-/5XBtCF6M+9frEXrrvfSWOdOC2q6I1L7oY7qbUVegNkp3kYVGihNZZnJIXGzo9rmwnA0IV7jI3o0pF/HDRqPeA==
@@ -6969,6 +6974,20 @@
69696974
magic-string "0.30.8"
69706975
unplugin "1.0.1"
69716976

6977+
"@sentry/[email protected]", "@sentry/bundler-plugin-core@^4.2.0":
6978+
version "4.2.0"
6979+
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-4.2.0.tgz#b607937f7cd0a769aa26974c4af3fca94abad63f"
6980+
integrity sha512-EDG6ELSEN/Dzm4KUQOynoI2suEAdPdgwaBXVN4Ww705zdrYT79OGh51rkz74KGhovt7GukaPf0Z9LJwORXUbhg==
6981+
dependencies:
6982+
"@babel/core" "^7.18.5"
6983+
"@sentry/babel-plugin-component-annotate" "4.2.0"
6984+
"@sentry/cli" "^2.51.0"
6985+
dotenv "^16.3.1"
6986+
find-up "^5.0.0"
6987+
glob "^9.3.2"
6988+
magic-string "0.30.8"
6989+
unplugin "1.0.1"
6990+
69726991
69736992
version "2.52.0"
69746993
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.52.0.tgz#05178cd819c2a33eb22a6e90bf7bb8f853f1b476"
@@ -7054,6 +7073,15 @@
70547073
unplugin "1.0.1"
70557074
uuid "^9.0.0"
70567075

7076+
"@sentry/webpack-plugin@^4.2.0":
7077+
version "4.2.0"
7078+
resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-4.2.0.tgz#00b89aeb1261ae15f7bc81ee9e5b5a23ca3d2dbf"
7079+
integrity sha512-2lPuvJhbiEOd/NAQv5EL8at9QVKchkEmWFDioDsOG6csFqbZ8hdWtTcbsXnhzH9j+CM1LmdeDNVjIF+SMoxCNg==
7080+
dependencies:
7081+
"@sentry/bundler-plugin-core" "4.2.0"
7082+
unplugin "1.0.1"
7083+
uuid "^9.0.0"
7084+
70577085
"@sigstore/protobuf-specs@^0.1.0":
70587086
version "0.1.0"
70597087
resolved "https://registry.yarnpkg.com/@sigstore/protobuf-specs/-/protobuf-specs-0.1.0.tgz#957cb64ea2f5ce527cc9cf02a096baeb0d2b99b4"

0 commit comments

Comments
 (0)