Skip to content

Commit 562b78c

Browse files
Fail fast if packaging step fails in production
Wrap finishOutput in try/catch inside production build promises to avoid hanging builds when copying artifacts fails. This ensures CI surfaces errors promptly
1 parent ca92bb9 commit 562b78c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

build.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, sourceBuil
148148
buildDependencies: {
149149
config: [
150150
path.resolve('build.mjs'),
151-
path.resolve('package.json'),
152-
path.resolve('package-lock.json'),
151+
...['package.json', 'package-lock.json', 'pnpm-lock.yaml', 'yarn.lock']
152+
.map((p) => path.resolve(p))
153+
.filter((p) => fs.existsSync(p)),
153154
],
154155
},
155156
},
@@ -537,8 +538,12 @@ async function build() {
537538
reject(err || new Error('webpack error'))
538539
return
539540
}
540-
await finishOutput(suffix, tmpDir)
541-
resolve()
541+
try {
542+
await finishOutput(suffix, tmpDir)
543+
resolve()
544+
} catch (copyErr) {
545+
reject(copyErr)
546+
}
542547
}),
543548
)
544549
}

0 commit comments

Comments
 (0)