From c89eed56b604bbd94a713e6d5111cd37b2b2dc00 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 12 Nov 2019 13:12:45 -0800 Subject: [PATCH] build: add ngJitMode to ng_rollup_bundle terser config (#33773) This adds a `tools/ng_rollup_bundle/terser_config.json` file to override the default terser_minified config provided by the rule. After this change, the layer violation in rules_nodejs can be fixed by removing `"global_defs": {"ngDevMode": false, "ngI18nClosureMode": false},` from `terser_config.default.json` in rules_nodejs. Change requested by Alex Rickabaugh in https://github.com/bazelbuild/rules_nodejs/pull/1338. PR Close #33773 --- tools/ng_rollup_bundle/BUILD.bazel | 5 ++++- tools/ng_rollup_bundle/ng_rollup_bundle.bzl | 1 + tools/ng_rollup_bundle/terser_config.json | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tools/ng_rollup_bundle/terser_config.json diff --git a/tools/ng_rollup_bundle/BUILD.bazel b/tools/ng_rollup_bundle/BUILD.bazel index c615a86bbb..a1e47c5f05 100644 --- a/tools/ng_rollup_bundle/BUILD.bazel +++ b/tools/ng_rollup_bundle/BUILD.bazel @@ -2,7 +2,10 @@ package(default_visibility = ["//visibility:public"]) load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") -exports_files(["rollup.config.js"]) +exports_files([ + "rollup.config.js", + "terser_config.json", +]) nodejs_binary( name = "rollup_with_build_optimizer", diff --git a/tools/ng_rollup_bundle/ng_rollup_bundle.bzl b/tools/ng_rollup_bundle/ng_rollup_bundle.bzl index fe327099c6..232451cc33 100644 --- a/tools/ng_rollup_bundle/ng_rollup_bundle.bzl +++ b/tools/ng_rollup_bundle/ng_rollup_bundle.bzl @@ -391,6 +391,7 @@ def ng_rollup_bundle(name, **kwargs): # maintain the comments off behavior. We pass the --comments flag with # a regex that always evaluates to false to do this. "args": ["--comments", "/bogus_string_to_suppress_all_comments^/"], + "config_file": "//tools/ng_rollup_bundle:terser_config.json", "sourcemap": False, } diff --git a/tools/ng_rollup_bundle/terser_config.json b/tools/ng_rollup_bundle/terser_config.json new file mode 100644 index 0000000000..aeed0b6732 --- /dev/null +++ b/tools/ng_rollup_bundle/terser_config.json @@ -0,0 +1,12 @@ +{ + "compress": { + "global_defs": {"ngDevMode": false, "ngI18nClosureMode": false, "ngJitMode": false}, + "keep_fnames": "bazel_no_debug", + "passes": 3, + "pure_getters": true, + "reduce_funcs": "bazel_no_debug", + "reduce_vars": "bazel_no_debug", + "sequences": "bazel_no_debug" + }, + "mangle": "bazel_no_debug" +} \ No newline at end of file