mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Prior to this change the FESM bundles have the license banner duplicated multiple of times in each published file. With this change we remove all the banners from the individual input files. A new banner will be appended at the top of the FESM using rollup's banner option. While there is a rollup plugin on NPM to strip these banners (https://github.com/mjeanroy/rollup-plugin-strip-banner) we could not use this as it does not support `.mjs`. PR Close #48560
83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
"""Provides the rollup and dist file generation macro."""
|
|
|
|
load("//tools:defaults.bzl", "rollup_bundle")
|
|
|
|
def zone_rollup_bundle(module_name, entry_point):
|
|
config_file = "//packages/zone.js:rollup.config.js"
|
|
rollup_bundle(
|
|
name = module_name + "-rollup",
|
|
config_file = config_file,
|
|
entry_point = entry_point + ".ts",
|
|
silent = True,
|
|
sourcemap = "false",
|
|
deps = [
|
|
"//packages/zone.js/lib",
|
|
"@npm//@rollup/plugin-commonjs",
|
|
"@npm//@rollup/plugin-node-resolve",
|
|
"@npm//magic-string",
|
|
],
|
|
)
|
|
|
|
def copy_dist(module_name, module_format, output_module_name, suffix, umd):
|
|
umd_output = umd
|
|
suffix_output = suffix
|
|
if umd == "umd":
|
|
umd_output = "umd."
|
|
if suffix == "min":
|
|
suffix_output = "min."
|
|
native.genrule(
|
|
name = module_name + "." + suffix_output + "dist",
|
|
srcs = [
|
|
"//packages/zone.js:" + module_name + "-rollup." + suffix_output + module_format,
|
|
],
|
|
outs = [
|
|
output_module_name + "." + umd_output + suffix_output + "js",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
cmd = "cp $< $@",
|
|
)
|
|
|
|
def generate_rollup_bundle(bundles):
|
|
for b in bundles.items():
|
|
module_name = b[0]
|
|
rollup_config = b[1]
|
|
if rollup_config.get("entrypoint") != None:
|
|
entry_point = rollup_config.get("entrypoint")
|
|
zone_rollup_bundle(
|
|
module_name = module_name + "-es5",
|
|
entry_point = entry_point,
|
|
)
|
|
zone_rollup_bundle(
|
|
module_name = module_name + "-es2015",
|
|
entry_point = entry_point,
|
|
)
|
|
else:
|
|
zone_rollup_bundle(
|
|
module_name = module_name + "-es5",
|
|
entry_point = rollup_config.get("es5"),
|
|
)
|
|
zone_rollup_bundle(
|
|
module_name = module_name + "-es2015",
|
|
entry_point = rollup_config.get("es2015"),
|
|
)
|
|
|
|
def generate_dist(bundles, output_format, umd):
|
|
module_format = "esm.js"
|
|
if output_format == "es5":
|
|
module_format = "es5umd.js"
|
|
for b in bundles:
|
|
module_name = b[0]
|
|
copy_dist(
|
|
module_name = module_name + "-" + output_format,
|
|
module_format = module_format,
|
|
output_module_name = module_name,
|
|
suffix = "",
|
|
umd = umd,
|
|
)
|
|
copy_dist(
|
|
module_name = module_name + "-" + output_format,
|
|
module_format = module_format,
|
|
output_module_name = module_name,
|
|
suffix = "min.",
|
|
umd = umd,
|
|
)
|