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
@ -53,19 +53,6 @@ def rules_angular_dev_dependencies():
|
||||
shorter.
|
||||
"""
|
||||
|
||||
# We have a source dependency on the Devkit repository, because it's built with
|
||||
# Bazel.
|
||||
# This allows us to edit sources and have the effect appear immediately without
|
||||
# re-packaging or "npm link"ing.
|
||||
# Even better, things like aspects will visit the entire graph including
|
||||
# ts_library rules in the devkit repository.
|
||||
http_archive(
|
||||
name = "angular_cli",
|
||||
sha256 = "8cf320ea58c321e103f39087376feea502f20eaf79c61a4fdb05c7286c8684fd",
|
||||
strip_prefix = "angular-cli-6.1.0-rc.0",
|
||||
url = "https://github.com/angular/angular-cli/archive/v6.1.0-rc.0.zip",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "org_brotli",
|
||||
sha256 = "774b893a0700b0692a76e2e5b7e7610dbbe330ffbe3fe864b4b52ca718061d5a",
|
||||
|
@ -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