Skip to content

Commit 46a4c3c

Browse files
authored
ref(nextjs): Simplify isBuild logic (#6594)
1 parent c65597f commit 46a4c3c

File tree

2 files changed

+1
-74
lines changed

2 files changed

+1
-74
lines changed

packages/nextjs/src/utils/isBuild.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,5 @@ import { NEXT_PHASE_PRODUCTION_BUILD } from './phases';
44
* Decide if the currently running process is part of the build phase or happening at runtime.
55
*/
66
export function isBuild(): boolean {
7-
if (
8-
// During build, the main process is invoked by
9-
// `node next build`
10-
// and child processes are invoked as
11-
// `node <path>/node_modules/.../jest-worker/processChild.js`.
12-
// The former is (obviously) easy to recognize, but the latter could happen at runtime as well. Fortunately, the main
13-
// process hits this file before any of the child processes do, so we're able to set an env variable which the child
14-
// processes can then check. During runtime, the main process is invoked as
15-
// `node next start`
16-
// or
17-
// `node /var/runtime/index.js`,
18-
// so we never drop into the `if` in the first place.
19-
process.argv.includes('build') ||
20-
process.env.SENTRY_BUILD_PHASE ||
21-
// This is set by next, but not until partway through the build process, which is why we need the above checks. That
22-
// said, in case this function isn't called until we're in a child process, it can serve as a good backup.
23-
process.env.NEXT_PHASE === NEXT_PHASE_PRODUCTION_BUILD
24-
) {
25-
process.env.SENTRY_BUILD_PHASE = 'true';
26-
return true;
27-
}
28-
29-
return false;
7+
return process.env.NEXT_PHASE === NEXT_PHASE_PRODUCTION_BUILD;
308
}

packages/nextjs/test/utils/isBuild.test.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)