build: update zone.js to use the new rollup_bundle (#33329)
PR Close #33329
This commit is contained in:
parent
e6045ee0b7
commit
7f2885ec7d
|
@ -44,6 +44,7 @@
|
||||||
"@bazel/jasmine": "0.40.0",
|
"@bazel/jasmine": "0.40.0",
|
||||||
"@bazel/karma": "0.40.0",
|
"@bazel/karma": "0.40.0",
|
||||||
"@bazel/protractor": "0.40.0",
|
"@bazel/protractor": "0.40.0",
|
||||||
|
"@bazel/rollup": "0.40.0",
|
||||||
"@bazel/terser": "0.40.0",
|
"@bazel/terser": "0.40.0",
|
||||||
"@bazel/typescript": "0.40.0",
|
"@bazel/typescript": "0.40.0",
|
||||||
"@microsoft/api-extractor": "^7.3.9",
|
"@microsoft/api-extractor": "^7.3.9",
|
||||||
|
|
|
@ -3,6 +3,8 @@ load("//packages/zone.js:bundles.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLO
|
||||||
|
|
||||||
exports_files([
|
exports_files([
|
||||||
"tsconfig.json",
|
"tsconfig.json",
|
||||||
|
"rollup-es5.config.js",
|
||||||
|
"rollup-es5_global-es2015.config.js",
|
||||||
])
|
])
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
|
|
|
@ -21,13 +21,12 @@ genrule(
|
||||||
[
|
[
|
||||||
rollup_bundle(
|
rollup_bundle(
|
||||||
name = b[0].replace("-", "_") + "_rollup",
|
name = b[0].replace("-", "_") + "_rollup",
|
||||||
|
config_file = "//packages/zone.js:rollup-es5.config.js",
|
||||||
entry_point = b[1] + ".ts",
|
entry_point = b[1] + ".ts",
|
||||||
globals = {
|
|
||||||
"electron": "electron",
|
|
||||||
},
|
|
||||||
license_banner = "//packages:license-banner.txt",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//packages/zone.js/lib",
|
"//packages/zone.js/lib",
|
||||||
|
"@npm//rollup-plugin-commonjs",
|
||||||
|
"@npm//rollup-plugin-node-resolve",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
for b in ES5_BUNDLES.items()
|
for b in ES5_BUNDLES.items()
|
||||||
|
@ -36,63 +35,24 @@ genrule(
|
||||||
[
|
[
|
||||||
rollup_bundle(
|
rollup_bundle(
|
||||||
name = b[0].replace("-", "_") + "_rollup",
|
name = b[0].replace("-", "_") + "_rollup",
|
||||||
|
config_file = "//packages/zone.js:rollup-es5_global-es2015.config.js",
|
||||||
entry_point = b[1] + ".ts",
|
entry_point = b[1] + ".ts",
|
||||||
global_name = "Zone",
|
|
||||||
license_banner = "//packages:license-banner.txt",
|
|
||||||
deps = [
|
deps = [
|
||||||
"//packages/zone.js/lib",
|
"//packages/zone.js/lib",
|
||||||
|
"@npm//rollup-plugin-commonjs",
|
||||||
|
"@npm//rollup-plugin-node-resolve",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
for b in ES5_GLOBAL_BUNDLES.items() + ES2015_BUNDLES.items()
|
for b in ES5_GLOBAL_BUNDLES.items() + ES2015_BUNDLES.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
# the es5 filegroups
|
|
||||||
[
|
|
||||||
filegroup(
|
|
||||||
name = b[0] + ".es5",
|
|
||||||
srcs = [":" + b[0].replace("-", "_") + "_rollup"],
|
|
||||||
output_group = "es5_umd",
|
|
||||||
)
|
|
||||||
for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
# the es5.min filegroups
|
|
||||||
[
|
|
||||||
filegroup(
|
|
||||||
name = b[0] + ".es5.min",
|
|
||||||
srcs = [":" + b[0].replace("-", "_") + "_rollup"],
|
|
||||||
output_group = "es5_umd_min",
|
|
||||||
)
|
|
||||||
for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
# the es2015 filegroups
|
|
||||||
[
|
|
||||||
filegroup(
|
|
||||||
name = b[0] + ".umd",
|
|
||||||
srcs = [":" + b[0].replace("-", "_") + "_rollup"],
|
|
||||||
output_group = "umd",
|
|
||||||
)
|
|
||||||
for b in ES2015_BUNDLES.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
# the es2015.min filegroups
|
|
||||||
[
|
|
||||||
filegroup(
|
|
||||||
name = b[0] + ".umd.min",
|
|
||||||
srcs = [":" + b[0].replace("-", "_") + "_rollup"],
|
|
||||||
output_group = "umd_min",
|
|
||||||
)
|
|
||||||
for b in ES2015_BUNDLES.items()
|
|
||||||
]
|
|
||||||
|
|
||||||
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
||||||
[
|
[
|
||||||
genrule(
|
genrule(
|
||||||
name = b[0] + "-dist",
|
name = b[0] + "-dist",
|
||||||
srcs = [
|
srcs = [
|
||||||
b[0] + ".es5",
|
b[0].replace("-", "_") + "_rollup.es5umd.js",
|
||||||
b[0] + ".es5.min",
|
b[0].replace("-", "_") + "_rollup.min.es5umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b[0] + ".js",
|
b[0] + ".js",
|
||||||
|
@ -114,7 +74,7 @@ genrule(
|
||||||
genrule(
|
genrule(
|
||||||
name = b[0] + "-dist-dev-test",
|
name = b[0] + "-dist-dev-test",
|
||||||
srcs = [
|
srcs = [
|
||||||
b[0] + ".es5",
|
b[0].replace("-", "_") + "_rollup.es5umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b[0] + ".dev.test.js",
|
b[0] + ".dev.test.js",
|
||||||
|
@ -131,7 +91,7 @@ genrule(
|
||||||
genrule(
|
genrule(
|
||||||
name = b + "-dist-dev-test",
|
name = b + "-dist-dev-test",
|
||||||
srcs = [
|
srcs = [
|
||||||
b + ".umd",
|
b.replace("-", "_") + "_rollup.umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b + ".dev.test.js",
|
b + ".dev.test.js",
|
||||||
|
@ -149,7 +109,7 @@ genrule(
|
||||||
genrule(
|
genrule(
|
||||||
name = b[0] + "-dist-test",
|
name = b[0] + "-dist-test",
|
||||||
srcs = [
|
srcs = [
|
||||||
b[0] + ".es5.min",
|
b[0].replace("-", "_") + "_rollup.min.es5umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b[0] + ".test.min.js",
|
b[0] + ".test.min.js",
|
||||||
|
@ -167,8 +127,8 @@ genrule(
|
||||||
genrule(
|
genrule(
|
||||||
name = b + "-dist",
|
name = b + "-dist",
|
||||||
srcs = [
|
srcs = [
|
||||||
b + ".umd",
|
b.replace("-", "_") + "_rollup.umd.js",
|
||||||
b + ".umd.min",
|
b.replace("-", "_") + "_rollup.min.umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b + ".js",
|
b + ".js",
|
||||||
|
@ -190,7 +150,7 @@ genrule(
|
||||||
genrule(
|
genrule(
|
||||||
name = b + "-dist-test",
|
name = b + "-dist-test",
|
||||||
srcs = [
|
srcs = [
|
||||||
b + ".umd.min",
|
b.replace("-", "_") + "_rollup.min.umd.js",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
b + ".test.min.js",
|
b + ".test.min.js",
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
const node = require('rollup-plugin-node-resolve');
|
||||||
|
const commonjs = require('rollup-plugin-commonjs');
|
||||||
|
|
||||||
|
const banner = `/**
|
||||||
|
* @license Angular v0.0.0-PLACEHOLDER
|
||||||
|
* (c) 2010-2019 Google LLC. https://angular.io/
|
||||||
|
* License: MIT
|
||||||
|
*/`;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
node({
|
||||||
|
mainFields: ['es2015', 'module', 'jsnext:main', 'main'],
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
],
|
||||||
|
external: ['electron'],
|
||||||
|
output: {globals: {electron: 'electron'}, banner},
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
const node = require('rollup-plugin-node-resolve');
|
||||||
|
const commonjs = require('rollup-plugin-commonjs');
|
||||||
|
|
||||||
|
const banner = `/**
|
||||||
|
* @license Angular v0.0.0-PLACEHOLDER
|
||||||
|
* (c) 2010-2019 Google LLC. https://angular.io/
|
||||||
|
* License: MIT
|
||||||
|
*/`;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
node({
|
||||||
|
mainFields: ['es2015', 'module', 'jsnext:main', 'main'],
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
],
|
||||||
|
output: {name: 'Zone', banner},
|
||||||
|
}
|
|
@ -14,19 +14,15 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
||||||
entry_point = env_entry_point,
|
entry_point = env_entry_point,
|
||||||
deps = [
|
deps = [
|
||||||
":" + name + "_env",
|
":" + name + "_env",
|
||||||
|
"@npm//rollup-plugin-commonjs",
|
||||||
|
"@npm//rollup-plugin-node-resolve",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
native.filegroup(
|
|
||||||
name = name + "_env_rollup.es5",
|
|
||||||
testonly = True,
|
|
||||||
srcs = [":" + name + "_env_rollup"],
|
|
||||||
output_group = "umd",
|
|
||||||
)
|
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = name + "_env_trim_map",
|
name = name + "_env_trim_map",
|
||||||
testonly = True,
|
testonly = True,
|
||||||
srcs = [
|
srcs = [
|
||||||
":" + name + "_env_rollup.es5",
|
":" + name + "_env_rollup.umd",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
name + "_env_rollup_trim_map.js",
|
name + "_env_rollup_trim_map.js",
|
||||||
|
@ -45,24 +41,18 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
||||||
name = name + "_rollup",
|
name = name + "_rollup",
|
||||||
testonly = True,
|
testonly = True,
|
||||||
entry_point = test_entry_point,
|
entry_point = test_entry_point,
|
||||||
globals = {
|
config_file = "//packages/zone.js:rollup-es5.config.js",
|
||||||
"electron": "electron",
|
|
||||||
},
|
|
||||||
deps = [
|
deps = [
|
||||||
":" + name + "_test",
|
":" + name + "_test",
|
||||||
|
"@npm//rollup-plugin-commonjs",
|
||||||
|
"@npm//rollup-plugin-node-resolve",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
native.filegroup(
|
|
||||||
name = name + "_rollup.es5",
|
|
||||||
testonly = True,
|
|
||||||
srcs = [":" + name + "_rollup"],
|
|
||||||
output_group = "umd",
|
|
||||||
)
|
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = name + "_trim_map",
|
name = name + "_trim_map",
|
||||||
testonly = True,
|
testonly = True,
|
||||||
srcs = [
|
srcs = [
|
||||||
":" + name + "_rollup.es5",
|
":" + name + "_rollup.umd",
|
||||||
],
|
],
|
||||||
outs = [
|
outs = [
|
||||||
name + "_rollup_trim_map.js",
|
name + "_rollup_trim_map.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Re-export of some bazel rules with repository-wide defaults."""
|
"""Re-export of some bazel rules with repository-wide defaults."""
|
||||||
|
|
||||||
load("@build_bazel_rules_nodejs//:index.bzl", _nodejs_binary = "nodejs_binary", _npm_package = "npm_package", _rollup_bundle = "rollup_bundle")
|
load("@build_bazel_rules_nodejs//:index.bzl", _nodejs_binary = "nodejs_binary", _npm_package = "npm_package")
|
||||||
load("@npm_bazel_jasmine//:index.bzl", _jasmine_node_test = "jasmine_node_test")
|
load("@npm_bazel_jasmine//:index.bzl", _jasmine_node_test = "jasmine_node_test")
|
||||||
load("@npm_bazel_karma//:index.bzl", _karma_web_test = "karma_web_test", _karma_web_test_suite = "karma_web_test_suite")
|
load("@npm_bazel_karma//:index.bzl", _karma_web_test = "karma_web_test", _karma_web_test_suite = "karma_web_test_suite")
|
||||||
load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
|
load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
|
||||||
|
@ -8,6 +8,9 @@ load("@npm_bazel_protractor//:index.bzl", _protractor_web_test_suite = "protract
|
||||||
load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
|
load("//packages/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
|
||||||
load("//tools/ng_rollup_bundle:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle")
|
load("//tools/ng_rollup_bundle:ng_rollup_bundle.bzl", _ng_rollup_bundle = "ng_rollup_bundle")
|
||||||
load("//tools:ng_benchmark.bzl", _ng_benchmark = "ng_benchmark")
|
load("//tools:ng_benchmark.bzl", _ng_benchmark = "ng_benchmark")
|
||||||
|
load("@npm_bazel_rollup//:index.bzl", _rollup_bundle = "rollup_bundle")
|
||||||
|
load("@npm_bazel_terser//:index.bzl", "terser_minified")
|
||||||
|
load("@npm//typescript:index.bzl", "tsc")
|
||||||
|
|
||||||
_DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test"
|
_DEFAULT_TSCONFIG_TEST = "//packages:tsconfig-test"
|
||||||
_INTERNAL_NG_MODULE_API_EXTRACTOR = "//packages/bazel/src/api-extractor:api_extractor"
|
_INTERNAL_NG_MODULE_API_EXTRACTOR = "//packages/bazel/src/api-extractor:api_extractor"
|
||||||
|
@ -263,11 +266,97 @@ def ng_rollup_bundle(deps = [], **kwargs):
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def rollup_bundle(**kwargs):
|
def rollup_bundle(name, testonly = False, **kwargs):
|
||||||
"""Default values for rollup_bundle"""
|
"""A drop in replacement for the rules nodejs [legacy rollup_bundle].
|
||||||
_rollup_bundle(
|
|
||||||
# code-splitting is turned on by default in nodejs rules 0.35.0
|
Runs [rollup_bundle], [terser_minified] and [babel] for downleveling to es5
|
||||||
# we want to default to remain off
|
to produce a number of output bundles.
|
||||||
enable_code_splitting = False,
|
|
||||||
**kwargs
|
es2015 iife : "%{name}.es2015.js"
|
||||||
|
es2015 iife minified : "%{name}.min.es2015.js"
|
||||||
|
es2015 iife minified (debug) : "%{name}.min_debug.es2015.js"
|
||||||
|
es5 iife : "%{name}.js"
|
||||||
|
es5 iife minified : "%{name}.min.js"
|
||||||
|
es5 iife minified (debug) : "%{name}.min_debug.js"
|
||||||
|
es5 umd : "%{name}.es5umd.js"
|
||||||
|
es5 umd minified : "%{name}.min.es5umd.js"
|
||||||
|
es2015 umd : "%{name}.umd.js"
|
||||||
|
es2015 umd minified : "%{name}.min.umd.js"
|
||||||
|
|
||||||
|
".js.map" files are also produced for each bundle.
|
||||||
|
|
||||||
|
[legacy rollup_bundle]: https://github.com/bazelbuild/rules_nodejs/blob/0.38.3/internal/rollup/rollup_bundle.bzl
|
||||||
|
[rollup_bundle]: https://bazelbuild.github.io/rules_nodejs/Rollup.html
|
||||||
|
[terser_minified]: https://bazelbuild.github.io/rules_nodejs/Terser.html
|
||||||
|
[babel]: https://babeljs.io/
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Common arguments for all terser_minified targets
|
||||||
|
common_terser_args = {
|
||||||
|
"args": ["--comments"],
|
||||||
|
"sourcemap": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
# es2015
|
||||||
|
_rollup_bundle(name = name + ".es2015", testonly = testonly, format = "iife", sourcemap = "true", **kwargs)
|
||||||
|
terser_minified(name = name + ".min.es2015", testonly = testonly, src = name + ".es2015", **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min.es2015.js", testonly = testonly, srcs = [name + ".min.es2015"])
|
||||||
|
terser_minified(name = name + ".min_debug.es2015", testonly = testonly, src = name + ".es2015", **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min_debug.es2015.js", testonly = testonly, srcs = [name + ".min_debug.es2015"])
|
||||||
|
|
||||||
|
# es5
|
||||||
|
tsc(
|
||||||
|
name = name,
|
||||||
|
testonly = testonly,
|
||||||
|
outs = [
|
||||||
|
name + ".js",
|
||||||
|
],
|
||||||
|
args = [
|
||||||
|
"$(location :%s.es2015.js)" % name,
|
||||||
|
"--types",
|
||||||
|
"--skipLibCheck",
|
||||||
|
"--target",
|
||||||
|
"es5",
|
||||||
|
"--lib",
|
||||||
|
"es2015,dom",
|
||||||
|
"--allowJS",
|
||||||
|
"--outFile",
|
||||||
|
"$(location :%s.js)" % name,
|
||||||
|
],
|
||||||
|
data = [
|
||||||
|
name + ".es2015.js",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
terser_minified(name = name + ".min", testonly = testonly, src = name + "", **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min.js", testonly = testonly, srcs = [name + ".min"])
|
||||||
|
terser_minified(name = name + ".min_debug", testonly = testonly, src = name + "", debug = True, **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min_debug.js", testonly = testonly, srcs = [name + ".min_debug"])
|
||||||
|
|
||||||
|
# umd
|
||||||
|
_rollup_bundle(name = name + ".umd", testonly = testonly, format = "umd", sourcemap = "true", **kwargs)
|
||||||
|
terser_minified(name = name + ".min.umd", testonly = testonly, src = name + ".umd", **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min.umd.js", testonly = testonly, srcs = [name + ".min.umd"])
|
||||||
|
tsc(
|
||||||
|
name = name + ".es5umd",
|
||||||
|
testonly = testonly,
|
||||||
|
outs = [
|
||||||
|
name + ".es5umd.js",
|
||||||
|
],
|
||||||
|
args = [
|
||||||
|
"$(location :%s.umd.js)" % name,
|
||||||
|
"--types",
|
||||||
|
"--skipLibCheck",
|
||||||
|
"--target",
|
||||||
|
"es5",
|
||||||
|
"--lib",
|
||||||
|
"es2015,dom",
|
||||||
|
"--allowJS",
|
||||||
|
"--outFile",
|
||||||
|
"$(location :%s.es5umd.js)" % name,
|
||||||
|
],
|
||||||
|
data = [
|
||||||
|
name + ".umd.js",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
terser_minified(name = name + ".min.es5umd", testonly = testonly, src = name + ".es5umd", **common_terser_args)
|
||||||
|
native.filegroup(name = name + ".min.es5umd.js", testonly = testonly, srcs = [name + ".min.es5umd"])
|
||||||
|
|
|
@ -315,6 +315,11 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
protractor "^5.4.2"
|
protractor "^5.4.2"
|
||||||
|
|
||||||
|
"@bazel/rollup@0.40.0":
|
||||||
|
version "0.40.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-0.40.0.tgz#8ee08e1967c1ff7d549ce81b676872fa7e45afdb"
|
||||||
|
integrity sha512-7ZKzOIfHm0lEc3G/o2ykCZQlc7xcKSHiwIV4GIeaYJIbFUnO/L0cmaWzxOhdlr7NFfTdXcltTFnCrG7wlaad9A==
|
||||||
|
|
||||||
"@bazel/terser@0.40.0":
|
"@bazel/terser@0.40.0":
|
||||||
version "0.40.0"
|
version "0.40.0"
|
||||||
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-0.40.0.tgz#e31c76c32055a6bdffc711b05b530ae8df7ed1d5"
|
resolved "https://registry.yarnpkg.com/@bazel/terser/-/terser-0.40.0.tgz#e31c76c32055a6bdffc711b05b530ae8df7ed1d5"
|
||||||
|
|
Loading…
Reference in New Issue