Skip to content

Commit 6724b9e

Browse files
gkalpakthePunderWoman
authored andcommitted
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 bazel-contrib/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 (4e6d69c). [1]: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.3.0 [2]: https://github.com/angular/angular/blob/fc64fa8e1af9e0bbab40d1b441743744a40c5581/WORKSPACE#L12 PR Close #40557
1 parent 6bf99e0 commit 6724b9e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scripts/build/zone-js-builder.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function buildZoneJsPackage(destPath) {
3535
console.info(`${scriptPath}:`);
3636
console.info(' Building zone.js npm package');
3737
console.info('##############################');
38-
exec(`${bazelCmd} run //packages/zone.js:npm_package.pack`);
38+
exec(`${bazelCmd} build //packages/zone.js:npm_package`);
3939

4040
// Create the output directory.
4141
const absDestPath = resolve(baseDir, destPath);
@@ -46,6 +46,12 @@ function buildZoneJsPackage(destPath) {
4646
const buildOutputDir = `${bazelBin}/packages/zone.js/npm_package`;
4747
const distTargetDir = `${absDestPath}/zone.js`;
4848

49+
// Also create an archive so we can test the package itself.
50+
// Currently, the `npm_package.pack` rule does not work on Windows, so run `npm pack` directly.
51+
//
52+
// TODO: Switch to `npm_package.pack`, once we upgrade to `bazelbuild/rules_nodejs` >=2.3.0.
53+
exec(`npm pack ${buildOutputDir}`, false, {cwd: baseDir});
54+
4955
console.info(`# Copy npm_package artifacts to ${distTargetDir}`);
5056
rm('-rf', distTargetDir);
5157
cp('-R', buildOutputDir, distTargetDir);

0 commit comments

Comments
 (0)