| 294 | }; |
| 295 | |
| 296 | function removeOptionalEsbuildDeps() { |
| 297 | const yarnGlobalPath = exec('yarn global dir').output?.trim() || ''; |
| 298 | if (!yarnGlobalPath) return false; |
| 299 | const pkgjson = `${yarnGlobalPath}/package.json`; |
| 300 | const data = existsSync(pkgjson) ? require(pkgjson) : {}; |
| 301 | data.resolutions ||= {}; |
| 302 | Object.assign(data.resolutions, Object.fromEntries([ |
| 303 | '@esbuild/linux-loong64', |
| 304 | 'esbuild-windows-32', |
| 305 | ...['android', 'darwin', 'freebsd', 'windows'] |
| 306 | .flatMap((i) => [`${i}-64`, `${i}-arm64`]) |
| 307 | .map((i) => `esbuild-${i}`), |
| 308 | ...['32', 'arm', 'mips64', 'ppc64', 'riscv64', 's390x'] |
| 309 | .map((i) => `esbuild-linux-${i}`), |
| 310 | ...['netbsd', 'openbsd', 'sunos'] |
| 311 | .map((i) => `esbuild-${i}-64`), |
| 312 | ].map((i) => [i, 'link:/dev/null']))); |
| 313 | exec(`mkdir -p ${yarnGlobalPath}`); |
| 314 | writeFileSync(pkgjson, JSON.stringify(data, null, 2)); |
| 315 | return true; |
| 316 | } |
| 317 | |
| 318 | function rollbackResolveField() { |
| 319 | const yarnGlobalPath = exec('yarn global dir').output?.trim() || ''; |