@@ -7,6 +7,7 @@ import { escapeStringForRegex, logger } from '@sentry/utils';
77import * as domainModule from 'domain' ;
88import * as path from 'path' ;
99
10+ import { isBuild } from './utils/isBuild' ;
1011import { buildMetadata } from './utils/metadata' ;
1112import { NextjsOptions } from './utils/nextjsOptions' ;
1213import { addIntegration } from './utils/userIntegrations' ;
@@ -21,23 +22,6 @@ export { ErrorBoundary, showReportDialog, withErrorBoundary } from '@sentry/reac
2122type GlobalWithDistDir = typeof global & { __rewriteFramesDistDir__ : string } ;
2223const domain = domainModule as typeof domainModule & { active : ( domainModule . Domain & Carrier ) | null } ;
2324
24- // During build, the main process is invoked by
25- // `node next build`
26- // and child processes are invoked as
27- // `node <path>/node_modules/.../jest-worker/processChild.js`.
28- // The former is (obviously) easy to recognize, but the latter could happen at runtime as well. Fortunately, the main
29- // process hits this file before any of the child processes do, so we're able to set an env variable which the child
30- // processes can then check. During runtime, the main process is invoked as
31- // `node next start`
32- // or
33- // `node /var/runtime/index.js`,
34- // so we never drop into the `if` in the first place.
35- let isBuild = false ;
36- if ( process . argv . includes ( 'build' ) || process . env . SENTRY_BUILD_PHASE ) {
37- process . env . SENTRY_BUILD_PHASE = 'true' ;
38- isBuild = true ;
39- }
40-
4125const isVercel = ! ! process . env . VERCEL ;
4226
4327/** Inits the Sentry NextJS SDK on node. */
@@ -140,12 +124,13 @@ function addServerIntegrations(options: NextjsOptions): void {
140124export type { SentryWebpackPluginOptions } from './config/types' ;
141125export { withSentryConfig } from './config' ;
142126export { withSentry } from './utils/withSentry' ;
127+ export { isBuild } from './utils/isBuild' ;
143128
144129// Wrap various server methods to enable error monitoring and tracing. (Note: This only happens for non-Vercel
145130// deployments, because the current method of doing the wrapping a) crashes Next 12 apps deployed to Vercel and
146131// b) doesn't work on those apps anyway. We also don't do it during build, because there's no server running in that
147132// phase.)
148- if ( ! isVercel && ! isBuild ) {
133+ if ( ! isVercel && ! isBuild ( ) ) {
149134 // Dynamically require the file because even importing from it causes Next 12 to crash on Vercel.
150135 // In environments where the JS file doesn't exist, such as testing, import the TS file.
151136 try {
0 commit comments