build(zone.js): do not error when build `zone.js` on Windows (#40557)

In older versions of `bazelbuild/rules_nodejs`, the `npm_package.pack`
rule does not work on Windows. This has been fixed in
bazelbuild/rules_nodejs#2257, but the fix is not available before
[version 2.3.0][1].

Currently, we use version 2.2.0 (see [WORKSPACE][2]). In order to allow
the `zone-js-builder.js` script to work on Windows, this commit switches
to using `npm pack` directly, intead of relying on `npm_package.pack`.

For reference, the version of `bazelbuild/rules_nodejs` was updated to
2.3.2 in PR #39636, but this was later reverted due to CI flakes
(4e6d69cc85).

[1]: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.3.0
[2]: fc64fa8e1a/WORKSPACE (L12)

PR Close #40557
This commit is contained in:
George Kalpakas 2021-01-25 18:05:58 +02:00 committed by Jessica Janiuk
parent 6bf99e0eda
commit 6724b9e755
1 changed files with 7 additions and 1 deletions

View File

@ -35,7 +35,7 @@ function buildZoneJsPackage(destPath) {
console.info(`${scriptPath}:`);
console.info(' Building zone.js npm package');
console.info('##############################');
exec(`${bazelCmd} run //packages/zone.js:npm_package.pack`);
exec(`${bazelCmd} build //packages/zone.js:npm_package`);
// Create the output directory.
const absDestPath = resolve(baseDir, destPath);
@ -46,6 +46,12 @@ function buildZoneJsPackage(destPath) {
const buildOutputDir = `${bazelBin}/packages/zone.js/npm_package`;
const distTargetDir = `${absDestPath}/zone.js`;
// Also create an archive so we can test the package itself.
// Currently, the `npm_package.pack` rule does not work on Windows, so run `npm pack` directly.
//
// TODO: Switch to `npm_package.pack`, once we upgrade to `bazelbuild/rules_nodejs` >=2.3.0.
exec(`npm pack ${buildOutputDir}`, false, {cwd: baseDir});
console.info(`# Copy npm_package artifacts to ${distTargetDir}`);
rm('-rf', distTargetDir);
cp('-R', buildOutputDir, distTargetDir);