build(bazel): Use local rollup & build-optimizer for ng_rollup_bundle (#28215)
The current build workflow depends on cross workspace dependency by installing angular-cli as a Bazel repository. This is not ideal because it introduces separate node_module directories other than the one installed by Angular through the yarn_install rule (ngdeps). This commit removes angular-cli from the Bazel workspace and installs rollup and @angular-devkit/build-optimizer locally. PR Close #28215
This commit is contained in:

committed by
Alex Rickabaugh

parent
73616ab237
commit
c1c87462fd
@ -13,13 +13,15 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
|
||||
|
||||
nodejs_binary(
|
||||
name = "rollup_with_build_optimizer",
|
||||
data = ["@angular_cli//packages/angular_devkit/build_optimizer:lib"],
|
||||
# Since our rule extends the one in rules_nodejs, we use the same runtime
|
||||
# dependency @build_bazel_rules_nodejs_rollup_deps. We don't need any
|
||||
# additional npm dependencies when we run rollup or uglify.
|
||||
entry_point = "build_bazel_rules_nodejs_rollup_deps/node_modules/rollup/bin/rollup",
|
||||
data = [
|
||||
"@ngdeps//@angular-devkit/build-optimizer",
|
||||
"@ngdeps//is-builtin-module",
|
||||
"@ngdeps//rollup",
|
||||
"@ngdeps//rollup-plugin-node-resolve",
|
||||
"@ngdeps//rollup-plugin-sourcemaps",
|
||||
],
|
||||
entry_point = "ngdeps/node_modules/rollup/bin/rollup",
|
||||
install_source_map_support = False,
|
||||
node_modules = "@build_bazel_rules_nodejs_rollup_deps//:node_modules",
|
||||
)
|
||||
|
||||
nodejs_binary(
|
||||
|
@ -43,7 +43,7 @@ PACKAGES = [
|
||||
PLUGIN_CONFIG = "{sideEffectFreeModules: [\n%s]}" % ",\n".join(
|
||||
[" '.esm5/{0}'".format(p) for p in PACKAGES],
|
||||
)
|
||||
BO_ROLLUP = "angular_cli/packages/angular_devkit/build_optimizer/src/build-optimizer/rollup-plugin.js"
|
||||
BO_ROLLUP = "ngdeps/node_modules/@angular-devkit/build-optimizer/src/build-optimizer/rollup-plugin.js"
|
||||
BO_PLUGIN = "require('%s').default(%s)" % (BO_ROLLUP, PLUGIN_CONFIG)
|
||||
|
||||
def _use_plain_rollup(ctx):
|
||||
|
Reference in New Issue
Block a user