Skip to content

Commit

Permalink
feat(rollup): provide es5 and minified umd bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Bedard committed Apr 21, 2019
1 parent 593d47d commit 65c1618
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/e2e/rollup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ filegroup(
output_group = "umd",
)

filegroup(
name = "bundle-outputgroups-es5_umd",
srcs = [":bundle"],
output_group = "es5_umd",
)

filegroup(
name = "bundle-outputgroups-es5_umd_min",
srcs = [":bundle"],
output_group = "es5_umd_min",
)

filegroup(
name = "bundle-outputgroups-es2015",
srcs = [":bundle"],
Expand Down Expand Up @@ -75,6 +87,8 @@ jasmine_node_test(
":bundle-outputgroups-es5_min",
":bundle-outputgroups-es5_min_debug",
":bundle-outputgroups-umd",
":bundle-outputgroups-es5_umd",
":bundle-outputgroups-es5_umd_min",
],
deps = [
"@npm//jasmine",
Expand Down
4 changes: 4 additions & 0 deletions internal/e2e/rollup/outputgroups.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ describe('outputgroups', () => {
checkExists('bundle.umd.js');
checkExists('bundle.umd.js.map');
});
it('should produce a es5_umd_min sourcemap', () => {
checkExists('bundle.min.es5umd.js');
checkExists('bundle.min.es5umd.js.map');
});
});
9 changes: 9 additions & 0 deletions internal/rollup/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ def _rollup_bundle(ctx):
# There is no UMD/CJS bundle when code-splitting but we still need to satisfy the output
_generate_code_split_entry(ctx, ctx.label.name + "_chunks", ctx.outputs.build_umd)
_generate_code_split_entry(ctx, ctx.label.name + "_chunks", ctx.outputs.build_cjs)
_generate_code_split_entry(ctx, ctx.label.name + "_chunks", ctx.outputs.build_es5_umd)
_generate_code_split_entry(ctx, ctx.label.name + "_chunks", ctx.outputs.build_es5_umd_min)

# There is no source map explorer output when code-splitting but we still need to satisfy the output
ctx.actions.expand_template(
Expand Down Expand Up @@ -496,6 +498,9 @@ def _rollup_bundle(ctx):
cjs_map = run_rollup(ctx, _collect_es2015_sources(ctx), cjs_rollup_config, ctx.outputs.build_cjs)
umd_rollup_config = write_rollup_config(ctx, filename = "_%s_umd.rollup.conf.js", output_format = "umd")
umd_map = run_rollup(ctx, _collect_es2015_sources(ctx), umd_rollup_config, ctx.outputs.build_umd)
_run_tsc(ctx, ctx.outputs.build_umd, ctx.outputs.build_es5_umd)
es5_umd_min_map = run_terser(ctx, ctx.outputs.build_es5_umd, ctx.outputs.build_es5_umd_min, config_name = ctx.label.name + "es5umd_min")

run_sourcemapexplorer(ctx, ctx.outputs.build_es5_min, es5_min_map, ctx.outputs.explore_html)

files = [ctx.outputs.build_es5_min, es5_min_map]
Expand All @@ -507,6 +512,8 @@ def _rollup_bundle(ctx):
es5 = depset([ctx.outputs.build_es5]),
es5_min = depset([ctx.outputs.build_es5_min, es5_min_map]),
es5_min_debug = depset([ctx.outputs.build_es5_min_debug, es5_min_debug_map]),
es5_umd = depset([ctx.outputs.build_es5_umd]),
es5_umd_min = depset([ctx.outputs.build_es5_umd_min, es5_umd_min_map]),
umd = depset([ctx.outputs.build_umd, umd_map]),
)

Expand Down Expand Up @@ -705,6 +712,8 @@ ROLLUP_OUTPUTS = {
"build_es5": "%{name}.js",
"build_es5_min": "%{name}.min.js",
"build_es5_min_debug": "%{name}.min_debug.js",
"build_es5_umd": "%{name}.es5umd.js",
"build_es5_umd_min": "%{name}.min.es5umd.js",
"build_umd": "%{name}.umd.js",
"explore_html": "%{name}.explore.html",
}
Expand Down

0 comments on commit 65c1618

Please sign in to comment.