parent
17b862cf82
commit
39ef57971c
|
@ -1,5 +1,5 @@
|
|||
load("//tools:defaults.bzl", "rollup_bundle")
|
||||
load("//packages/zone.js:bundles.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLOBAL_BUNDLES")
|
||||
load("//packages/zone.js/dist:tools.bzl", "generate_dist", "zone_rollup_bundle")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
@ -18,147 +18,22 @@ genrule(
|
|||
cmd = "cp $< $@",
|
||||
)
|
||||
|
||||
[
|
||||
rollup_bundle(
|
||||
name = b[0].replace("-", "_") + "_rollup",
|
||||
zone_rollup_bundle(
|
||||
bundles = ES5_BUNDLES.items(),
|
||||
config_file = "//packages/zone.js:rollup-es5.config.js",
|
||||
entry_point = b[1] + ".ts",
|
||||
deps = [
|
||||
"//packages/zone.js/lib",
|
||||
"@npm//rollup-plugin-commonjs",
|
||||
"@npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
for b in ES5_BUNDLES.items()
|
||||
]
|
||||
|
||||
[
|
||||
rollup_bundle(
|
||||
name = b[0].replace("-", "_") + "_rollup",
|
||||
zone_rollup_bundle(
|
||||
bundles = ES5_GLOBAL_BUNDLES.items() + ES2015_BUNDLES.items(),
|
||||
config_file = "//packages/zone.js:rollup-es5_global-es2015.config.js",
|
||||
entry_point = b[1] + ".ts",
|
||||
deps = [
|
||||
"//packages/zone.js/lib",
|
||||
"@npm//rollup-plugin-commonjs",
|
||||
"@npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
for b in ES5_GLOBAL_BUNDLES.items() + ES2015_BUNDLES.items()
|
||||
]
|
||||
|
||||
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
||||
[
|
||||
genrule(
|
||||
name = b[0] + "-dist",
|
||||
srcs = [
|
||||
b[0].replace("-", "_") + "_rollup.es5umd.js",
|
||||
b[0].replace("-", "_") + "_rollup.min.es5umd.js",
|
||||
],
|
||||
outs = [
|
||||
b[0] + ".js",
|
||||
b[0] + ".min.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
# remove the last line '//# sourceMappingURL=b[0].umd.js.map' because we don't release
|
||||
# source map for now
|
||||
"sed '$$d' $(@D)/" + b[0].replace("-", "_") + "_rollup.es5umd.js > $(@D)/" + b[0] + ".js",
|
||||
"cp $(@D)/" + b[0].replace("-", "_") + "_rollup.min.es5umd.js $(@D)/" + b[0] + ".min.js",
|
||||
]),
|
||||
generate_dist(
|
||||
bundles = ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items(),
|
||||
module = "es5",
|
||||
)
|
||||
for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items()
|
||||
]
|
||||
|
||||
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
||||
[
|
||||
genrule(
|
||||
name = b[0] + "-dist-dev-test",
|
||||
srcs = [
|
||||
b[0].replace("-", "_") + "_rollup.es5umd.js",
|
||||
],
|
||||
outs = [
|
||||
b[0] + ".dev.test.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
"cp $(@D)/" + b[0].replace("-", "_") + "_rollup.es5umd.js $(@D)/" + b[0] + ".dev.test.js",
|
||||
]),
|
||||
generate_dist(
|
||||
bundles = ES2015_BUNDLES.items(),
|
||||
module = "",
|
||||
)
|
||||
for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items()
|
||||
]
|
||||
|
||||
[
|
||||
genrule(
|
||||
name = b + "-dist-dev-test",
|
||||
srcs = [
|
||||
b.replace("-", "_") + "_rollup.umd.js",
|
||||
],
|
||||
outs = [
|
||||
b + ".dev.test.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
"cp $(@D)/" + b.replace("-", "_") + "_rollup.umd.js $(@D)/" + b + ".dev.test.js",
|
||||
]),
|
||||
)
|
||||
for b in ES2015_BUNDLES
|
||||
]
|
||||
|
||||
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
||||
[
|
||||
genrule(
|
||||
name = b[0] + "-dist-test",
|
||||
srcs = [
|
||||
b[0].replace("-", "_") + "_rollup.min.es5umd.js",
|
||||
],
|
||||
outs = [
|
||||
b[0] + ".test.min.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
"cp $(@D)/" + b[0].replace("-", "_") + "_rollup.min.es5umd.js $(@D)/" + b[0] + ".test.min.js",
|
||||
]),
|
||||
)
|
||||
for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items()
|
||||
]
|
||||
|
||||
# Extract and rename each es2015 bundle to a .js and .min.js in the dist/ dir
|
||||
[
|
||||
genrule(
|
||||
name = b + "-dist",
|
||||
srcs = [
|
||||
b.replace("-", "_") + "_rollup.umd.js",
|
||||
b.replace("-", "_") + "_rollup.min.umd.js",
|
||||
],
|
||||
outs = [
|
||||
b + ".js",
|
||||
b + ".min.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
# remove the last line '//# sourceMappingURL=b[0].umd.js.map' because we don't release
|
||||
# source map for now
|
||||
"sed '$$d' $(@D)/" + b.replace("-", "_") + "_rollup.umd.js > $(@D)/" + b + ".js",
|
||||
"cp $(@D)/" + b.replace("-", "_") + "_rollup.min.umd.js $(@D)/" + b + ".min.js",
|
||||
]),
|
||||
)
|
||||
for b in ES2015_BUNDLES
|
||||
]
|
||||
|
||||
# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
|
||||
[
|
||||
genrule(
|
||||
name = b + "-dist-test",
|
||||
srcs = [
|
||||
b.replace("-", "_") + "_rollup.min.umd.js",
|
||||
],
|
||||
outs = [
|
||||
b + ".test.min.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $(@D)",
|
||||
"cp $(@D)/" + b.replace("-", "_") + "_rollup.min.umd.js $(@D)/" + b + ".test.min.js",
|
||||
]),
|
||||
)
|
||||
for b in ES2015_BUNDLES
|
||||
]
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
"""Provides the rollup and dist file generation macro."""
|
||||
|
||||
load("//tools:defaults.bzl", "rollup_bundle")
|
||||
|
||||
def zone_rollup_bundle(config_file, bundles):
|
||||
for b in bundles:
|
||||
rollup_bundle(
|
||||
name = b[0] + "-rollup",
|
||||
config_file = config_file,
|
||||
entry_point = b[1] + ".ts",
|
||||
sourcemap = "false",
|
||||
deps = [
|
||||
"//packages/zone.js/lib",
|
||||
"@npm//rollup-plugin-commonjs",
|
||||
"@npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
|
||||
def generate_dist(module, bundles):
|
||||
for b in bundles:
|
||||
native.genrule(
|
||||
name = b[0] + "-dist",
|
||||
srcs = [
|
||||
b[0] + "-rollup." + module + "umd.js",
|
||||
b[0] + "-rollup.min." + module + "umd.js",
|
||||
],
|
||||
outs = [
|
||||
b[0] + ".js",
|
||||
b[0] + ".min.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"cp $(@D)/" + b[0] + "-rollup." + module + "umd.js $(@D)/" + b[0] + ".js",
|
||||
"cp $(@D)/" + b[0] + "-rollup.min." + module + "umd.js $(@D)/" + b[0] + ".min.js",
|
||||
]),
|
||||
)
|
|
@ -278,15 +278,15 @@ test_deps = [
|
|||
test_entry_point = ":browser_entry_point.ts"
|
||||
|
||||
karma_tests = {
|
||||
"browser_test": ["//packages/zone.js/dist:zone-testing-bundle-dist-dev-test"],
|
||||
"browser_test": ["//packages/zone.js/dist:zone-testing-bundle.js"],
|
||||
"browser_green_test": [
|
||||
"//packages/zone.js/dist:zone-evergreen-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-testing-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-evergreen.js",
|
||||
"//packages/zone.js/dist:zone-testing.js",
|
||||
],
|
||||
"browser_legacy_test": [
|
||||
"//packages/zone.js/dist:zone-legacy-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-evergreen-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-testing-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-legacy.js",
|
||||
"//packages/zone.js/dist:zone-evergreen.js",
|
||||
"//packages/zone.js/dist:zone-testing.js",
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -305,8 +305,8 @@ karma_test(
|
|||
karma_test(
|
||||
name = "browser_shadydom",
|
||||
bootstraps = {"browser_shadydom": [
|
||||
"//packages/zone.js/dist:zone-testing-bundle-dist-dev-test",
|
||||
"//packages/zone.js/dist:webapis-shadydom-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-testing-bundle.js",
|
||||
"//packages/zone.js/dist:webapis-shadydom.js",
|
||||
]},
|
||||
ci = False,
|
||||
env_deps = [
|
||||
|
|
|
@ -11,6 +11,7 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
|||
rollup_bundle(
|
||||
name = name + "_env_rollup",
|
||||
testonly = True,
|
||||
sourcemap = "false",
|
||||
entry_point = env_entry_point,
|
||||
deps = [
|
||||
":" + name + "_env",
|
||||
|
@ -18,19 +19,6 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
|||
"@npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
native.genrule(
|
||||
name = name + "_env_trim_map",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
":" + name + "_env_rollup.umd",
|
||||
],
|
||||
outs = [
|
||||
name + "_env_rollup_trim_map.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"cp $(@D)/" + name + "_env_rollup.umd.js $@",
|
||||
]),
|
||||
)
|
||||
ts_library(
|
||||
name = name + "_test",
|
||||
testonly = True,
|
||||
|
@ -40,6 +28,7 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
|||
rollup_bundle(
|
||||
name = name + "_rollup",
|
||||
testonly = True,
|
||||
sourcemap = "false",
|
||||
entry_point = test_entry_point,
|
||||
config_file = "//packages/zone.js:rollup-es5.config.js",
|
||||
deps = [
|
||||
|
@ -48,19 +37,6 @@ def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, tes
|
|||
"@npm//rollup-plugin-node-resolve",
|
||||
],
|
||||
)
|
||||
native.genrule(
|
||||
name = name + "_trim_map",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
":" + name + "_rollup.umd",
|
||||
],
|
||||
outs = [
|
||||
name + "_rollup_trim_map.js",
|
||||
],
|
||||
cmd = " && ".join([
|
||||
"cp $(@D)/" + name + "_rollup.umd.js $@",
|
||||
]),
|
||||
)
|
||||
|
||||
def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point, bootstraps, ci):
|
||||
first = True
|
||||
|
@ -71,15 +47,15 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
|
|||
first = False
|
||||
karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point)
|
||||
_karma_test_required_dist_files = [
|
||||
"//packages/zone.js/dist:task-tracking-dist-dev-test",
|
||||
"//packages/zone.js/dist:wtf-dist-dev-test",
|
||||
"//packages/zone.js/dist:webapis-notification-dist-dev-test",
|
||||
"//packages/zone.js/dist:webapis-media-query-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-patch-canvas-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-patch-fetch-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-patch-resize-observer-dist-dev-test",
|
||||
"//packages/zone.js/dist:zone-patch-user-media-dist-dev-test",
|
||||
":" + name + "_trim_map",
|
||||
"//packages/zone.js/dist:task-tracking.js",
|
||||
"//packages/zone.js/dist:wtf.js",
|
||||
"//packages/zone.js/dist:webapis-notification.js",
|
||||
"//packages/zone.js/dist:webapis-media-query.js",
|
||||
"//packages/zone.js/dist:zone-patch-canvas.js",
|
||||
"//packages/zone.js/dist:zone-patch-fetch.js",
|
||||
"//packages/zone.js/dist:zone-patch-resize-observer.js",
|
||||
"//packages/zone.js/dist:zone-patch-user-media.js",
|
||||
":" + name + "_rollup.umd",
|
||||
]
|
||||
|
||||
karma_web_test_suite(
|
||||
|
@ -88,7 +64,7 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
|
|||
"fake_entry.js",
|
||||
],
|
||||
bootstrap = [
|
||||
":" + name + "_env_trim_map",
|
||||
":" + name + "_env_rollup.umd",
|
||||
] + bootstrap +
|
||||
_karma_test_required_dist_files,
|
||||
browsers = ["//tools/browsers:chromium"],
|
||||
|
@ -111,8 +87,8 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
|
|||
],
|
||||
bootstrap = [
|
||||
":saucelabs.js",
|
||||
":" + name + "_env_trim_map",
|
||||
"//packages/zone.js/dist:zone-testing-bundle-dist-test",
|
||||
":" + name + "_env_rollup.umd",
|
||||
"//packages/zone.js/dist:zone-testing-bundle.min.js",
|
||||
] + _karma_test_required_dist_files,
|
||||
browsers = ["//tools/browsers:chromium"],
|
||||
config_file = "//:karma-js.conf.js",
|
||||
|
|
|
@ -324,7 +324,7 @@ def ng_rollup_bundle(deps = [], **kwargs):
|
|||
**kwargs
|
||||
)
|
||||
|
||||
def rollup_bundle(name, testonly = False, **kwargs):
|
||||
def rollup_bundle(name, testonly = False, sourcemap = "true", **kwargs):
|
||||
"""A drop in replacement for the rules nodejs [legacy rollup_bundle].
|
||||
|
||||
Runs [rollup_bundle], [terser_minified] and [babel] for downleveling to es5
|
||||
|
@ -356,7 +356,7 @@ def rollup_bundle(name, testonly = False, **kwargs):
|
|||
}
|
||||
|
||||
# es2015
|
||||
_rollup_bundle(name = name + ".es2015", testonly = testonly, format = "iife", sourcemap = "true", **kwargs)
|
||||
_rollup_bundle(name = name + ".es2015", testonly = testonly, format = "iife", sourcemap = sourcemap, **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)
|
||||
|
@ -391,7 +391,7 @@ def rollup_bundle(name, testonly = False, **kwargs):
|
|||
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)
|
||||
_rollup_bundle(name = name + ".umd", testonly = testonly, format = "umd", sourcemap = sourcemap, **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(
|
||||
|
|
Loading…
Reference in New Issue