Revert "build: add a before-all-other bootstrap script that patches require (#34589)" (#34730)

This reverts commit c3e8439954.

PR Close #34730
This commit is contained in:
atscott
2020-01-10 13:39:40 -08:00
parent 66fbc2a1b8
commit b788c36909
10 changed files with 43 additions and 34 deletions

View File

@ -2,8 +2,6 @@ load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
exports_files(["bazel_patch_require.js"])
ts_library(
name = "browser",
testonly = 1,

View File

@ -1,26 +0,0 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Load the Bazel Node runfiles helper script and patch the NodeJS module resolution. This is
// necessary to ensure that imports are properly resolved in Bazel. By default, the module
// resolution is patched in `nodejs_binary` targets when the main script loads, but since we
// --require boostrap scripts before the main script, this bootstrap script is loaded first so that
// subsequent bootstrap scripts can resolve their imports.
//
// We're in a valley with the runfiles support right now having removed the `bootstrap` attribute
// for rule_nodejs 1.0 but not applied the linker to run targets yet in rules_nodejs. In a near
// future rules_nodejs release, the runfiles helper won't be required as standard node module
// resolution works with the linker.
//
// We could have left the `bootstrap` attribute in for 1.0 and removed it for 2.0 but since we had
// an alternate approach that we're using here that isn't going to be broken in the future by the
// linker being added we decided to pull it for 1.0 so that we have fewer major breaking changes in
// 2.0.
if (process.env['BAZEL_NODE_RUNFILES_HELPER']) {
require(process.env['BAZEL_NODE_RUNFILES_HELPER']).patchRequire();
}

View File

@ -6,6 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/
// bootstrap the bazel require patch since this bootstrap script is loaded with
// `--node_options=--require=$(rlocation $(location script.js))`
if (process.env['BAZEL_NODE_RUNFILES_HELPER']) {
require(process.env['BAZEL_NODE_RUNFILES_HELPER'] as string).patchRequire();
}
import 'zone.js/lib/node/rollup-main';
import 'zone.js/lib/zone-spec/long-stack-trace';
import 'zone.js/lib/zone-spec/task-tracking';