-
Notifications
You must be signed in to change notification settings - Fork 26.5k
/
build-native.cjs
executable file
·51 lines (46 loc) · 1.21 KB
/
build-native.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
const { NEXT_DIR, booleanArg, execAsyncWithOutput } = require('./pack-util.cjs')
const { rmSync } = require('fs')
const path = require('path')
const args = process.argv.slice(2)
// strip --no-build when called from pack-next.cjs
booleanArg(args, '--no-build')
const targetDir = path.join(NEXT_DIR, 'target')
module.exports = (async () => {
for (let i = 0; i < 2; i++) {
try {
await execAsyncWithOutput(
'Build native modules',
['pnpm', 'run', 'swc-build-native', ...args],
{
shell: process.platform === 'win32' ? 'powershell.exe' : false,
env: {
COLOR: 'always',
TTY: '1',
...process.env,
},
}
)
} catch (e) {
if (
e.stderr
.toString()
.includes('the compiler unexpectedly panicked. this is a bug.')
) {
rmSync(path.join(targetDir, 'release/incremental'), {
recursive: true,
force: true,
})
rmSync(path.join(targetDir, 'debug/incremental'), {
recursive: true,
force: true,
})
continue
}
delete e.stdout
delete e.stderr
throw e
}
break
}
})()