refactor: handle breaking changes in rules_nodejs 1.0.0 (#34589)

The major one that affects the angular repo is the removal of the bootstrap attribute in nodejs_binary, nodejs_test and jasmine_node_test in favor of using templated_args --node_options=--require=/path/to/script. The side-effect of this is that the bootstrap script does not get the require.resolve patches with explicitly loading the targets _loader.js file.

PR Close #34589
This commit is contained in:
Greg Magolan
2019-12-28 18:14:36 -08:00
committed by atscott
parent 96643e7ce2
commit 9bb349e1c8
69 changed files with 318 additions and 131 deletions

View File

@ -68,8 +68,6 @@ ts_library(
testonly = True,
srcs = glob(["node/*.ts"]) + [
"node-env-setup.ts",
"node_entry_point.ts",
"node_entry_point_no_patch_clock.ts",
"test-env-setup-jasmine-no-patch-clock.ts",
],
deps = [
@ -85,12 +83,45 @@ ts_library(
],
)
ts_library(
name = "node_entry_point",
testonly = True,
srcs = ["node_entry_point.ts"],
deps = [
":common_spec_env",
":common_spec_srcs",
":common_spec_util",
"//packages/zone.js/lib",
"@npm//@types/shelljs",
"@npm//@types/systemjs",
"@npm//rxjs",
"@npm//shelljs",
"@npm//systemjs",
],
)
ts_library(
name = "node_entry_point_no_patch_clock",
testonly = True,
srcs = ["node_entry_point_no_patch_clock.ts"],
deps = [
":common_spec_env",
":common_spec_srcs",
":common_spec_util",
"//packages/zone.js/lib",
"@npm//@types/shelljs",
"@npm//@types/systemjs",
"@npm//rxjs",
"@npm//shelljs",
"@npm//systemjs",
],
)
ts_library(
name = "bluebird_spec",
testonly = True,
srcs = [
"extra/bluebird.spec.ts",
"node_bluebird_entry_point.ts",
],
deps = [
":common_spec_env",
@ -100,13 +131,33 @@ ts_library(
)
ts_library(
name = "error_spec",
name = "node_bluebird_entry_point",
testonly = True,
srcs = [
"node_error_disable_policy_entry_point.ts",
"node_error_entry_point.ts",
"node_error_lazy_policy_entry_point.ts",
srcs = ["node_bluebird_entry_point.ts"],
deps = [
":common_spec_env",
"//packages/zone.js/lib",
"@npm//bluebird",
],
)
ts_library(
name = "node_error_disable_policy_entry_point",
testonly = True,
srcs = ["node_error_disable_policy_entry_point.ts"],
deps = [
":common_spec_env",
":common_spec_util",
":error_spec_srcs",
":node_error_entry_point",
"//packages/zone.js/lib",
],
)
ts_library(
name = "node_error_entry_point",
testonly = True,
srcs = ["node_error_entry_point.ts"],
deps = [
":common_spec_env",
":common_spec_util",
@ -115,53 +166,61 @@ ts_library(
],
)
ts_library(
name = "node_error_lazy_policy_entry_point",
testonly = True,
srcs = ["node_error_lazy_policy_entry_point.ts"],
deps = [
":common_spec_env",
":common_spec_util",
":error_spec_srcs",
":node_error_entry_point",
"//packages/zone.js/lib",
],
)
jasmine_node_test(
name = "test_node",
bootstrap = [
"angular/packages/zone.js/test/node_entry_point.js",
],
templated_args = ["--node_options=--require=$(rlocation $(location :node_entry_point_es5))"],
deps = [
":node_entry_point_es5",
":test_node_lib",
],
)
jasmine_node_test(
name = "test_node_no_jasmine_clock",
bootstrap = [
"angular/packages/zone.js/test/node_entry_point_no_patch_clock.js",
],
templated_args = ["--node_options=--require=$(rlocation $(location :node_entry_point_no_patch_clock_es5))"],
deps = [
":node_entry_point_no_patch_clock_es5",
":test_node_lib",
],
)
jasmine_node_test(
name = "test_node_bluebird",
bootstrap = [
"angular/packages/zone.js/test/node_bluebird_entry_point.js",
],
templated_args = ["--node_options=--require=$(rlocation $(location :node_bluebird_entry_point_es5))"],
deps = [
":bluebird_spec",
":node_bluebird_entry_point_es5",
],
)
jasmine_node_test(
name = "test_node_error_disable_policy",
bootstrap = [
"angular/packages/zone.js/test/node_error_disable_policy_entry_point.js",
],
templated_args = ["--node_options=--require=$(rlocation $(location :node_error_disable_policy_entry_point_es5))"],
deps = [
":error_spec",
":node_error_disable_policy_entry_point",
":node_error_disable_policy_entry_point_es5",
],
)
jasmine_node_test(
name = "test_node_error_lazy_policy",
bootstrap = [
"angular/packages/zone.js/test/node_error_lazy_policy_entry_point.js",
],
templated_args = ["--node_options=--require=$(rlocation $(location :node_error_lazy_policy_entry_point_es5))"],
deps = [
":error_spec",
":node_error_lazy_policy_entry_point",
":node_error_lazy_policy_entry_point_es5",
],
)

View File

@ -6,6 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
if (process.env['TEST_SRCDIR']) {
// bootstrap the bazel require resolve patch since this
// script is a bootstrap script loaded with --node_options=--require=...
const path = require('path');
require(path.posix.join(
process.env['TEST_SRCDIR'], process.env['TEST_WORKSPACE'],
(process.env['TEST_BINARY'] as string).replace(/\.(sh|bat)$/, '_loader.js'), ));
}
// Must be loaded before zone loads, so that zone can detect WTF.
import './test_fake_polyfill';

View File

@ -13,6 +13,15 @@
* found in the LICENSE file at https://angular.io/license
*/
if (process.env['TEST_SRCDIR']) {
// bootstrap the bazel require resolve patch since this
// script is a bootstrap script loaded with --node_options=--require=...
const path = require('path');
require(path.posix.join(
process.env['TEST_SRCDIR'], process.env['TEST_WORKSPACE'],
(process.env['TEST_BINARY'] as string).replace(/\.(sh|bat)$/, '_loader.js'), ));
}
// Must be loaded before zone loads, so that zone can detect WTF.
import './node-env-setup';
import './test_fake_polyfill';

View File

@ -13,6 +13,15 @@
* found in the LICENSE file at https://angular.io/license
*/
if (process.env['TEST_SRCDIR']) {
// bootstrap the bazel require resolve patch since this
// script is a bootstrap script loaded with --node_options=--require=...
const path = require('path');
require(path.posix.join(
process.env['TEST_SRCDIR'], process.env['TEST_WORKSPACE'],
(process.env['TEST_BINARY'] as string).replace(/\.(sh|bat)$/, '_loader.js'), ));
}
// Must be loaded before zone loads, so that zone can detect WTF.
import './node-env-setup';
import './test_fake_polyfill';

View File

@ -6,6 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
if (process.env['TEST_SRCDIR']) {
// bootstrap the bazel require resolve patch since this
// script is a bootstrap script loaded with --node_options=--require=...
const path = require('path');
require(path.posix.join(
process.env['TEST_SRCDIR'], process.env['TEST_WORKSPACE'],
(process.env['TEST_BINARY'] as string).replace(/\.(sh|bat)$/, '_loader.js'), ));
}
process.env['errorpolicy'] = (global as any)['__Zone_Error_BlacklistedStackFrames_policy'] =
'disable';
import './node_error_entry_point';

View File

@ -6,5 +6,14 @@
* found in the LICENSE file at https://angular.io/license
*/
if (process.env['TEST_SRCDIR']) {
// bootstrap the bazel require resolve patch since this
// script is a bootstrap script loaded with --node_options=--require=...
const path = require('path');
require(path.posix.join(
process.env['TEST_SRCDIR'], process.env['TEST_WORKSPACE'],
(process.env['TEST_BINARY'] as string).replace(/\.(sh|bat)$/, '_loader.js'), ));
}
process.env['errorpolicy'] = (global as any)['__Zone_Error_BlacklistedStackFrames_policy'] = 'lazy';
import './node_error_entry_point';