@@ -7,6 +7,7 @@ import { escapeStringForRegex, logger } from '@sentry/utils';
7
7
import * as domainModule from 'domain' ;
8
8
import * as path from 'path' ;
9
9
10
+ import { isBuild } from './utils/isBuild' ;
10
11
import { buildMetadata } from './utils/metadata' ;
11
12
import { NextjsOptions } from './utils/nextjsOptions' ;
12
13
import { addIntegration } from './utils/userIntegrations' ;
@@ -21,23 +22,6 @@ export { ErrorBoundary, showReportDialog, withErrorBoundary } from '@sentry/reac
21
22
type GlobalWithDistDir = typeof global & { __rewriteFramesDistDir__ : string } ;
22
23
const domain = domainModule as typeof domainModule & { active : ( domainModule . Domain & Carrier ) | null } ;
23
24
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
-
41
25
const isVercel = ! ! process . env . VERCEL ;
42
26
43
27
/** Inits the Sentry NextJS SDK on node. */
@@ -140,12 +124,13 @@ function addServerIntegrations(options: NextjsOptions): void {
140
124
export type { SentryWebpackPluginOptions } from './config/types' ;
141
125
export { withSentryConfig } from './config' ;
142
126
export { withSentry } from './utils/withSentry' ;
127
+ export { isBuild } from './utils/isBuild' ;
143
128
144
129
// Wrap various server methods to enable error monitoring and tracing. (Note: This only happens for non-Vercel
145
130
// deployments, because the current method of doing the wrapping a) crashes Next 12 apps deployed to Vercel and
146
131
// b) doesn't work on those apps anyway. We also don't do it during build, because there's no server running in that
147
132
// phase.)
148
- if ( ! isVercel && ! isBuild ) {
133
+ if ( ! isVercel && ! isBuild ( ) ) {
149
134
// Dynamically require the file because even importing from it causes Next 12 to crash on Vercel.
150
135
// In environments where the JS file doesn't exist, such as testing, import the TS file.
151
136
try {
0 commit comments