diff --git a/internal/e2e/rollup/BUILD.bazel b/internal/e2e/rollup/BUILD.bazel index 7343da560f..99041bf140 100644 --- a/internal/e2e/rollup/BUILD.bazel +++ b/internal/e2e/rollup/BUILD.bazel @@ -27,6 +27,8 @@ jasmine_node_test( ":bundle", ":bundle.cjs.js", ":bundle.umd.js", + ":bundle.es5umd.js", + ":bundle.min.es5umd.js", ":bundle.min_debug.js", ], deps = [ @@ -48,6 +50,24 @@ filegroup( output_group = "umd", ) +filegroup( + name = "bundle-outputgroups-umd_min", + srcs = [":bundle"], + output_group = "umd_min", +) + +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"], @@ -74,7 +94,10 @@ jasmine_node_test( ":bundle-outputgroups-es2015", ":bundle-outputgroups-es5_min", ":bundle-outputgroups-es5_min_debug", + ":bundle-outputgroups-es5_umd", + ":bundle-outputgroups-es5_umd_min", ":bundle-outputgroups-umd", + ":bundle-outputgroups-umd_min", ], deps = [ "@npm//jasmine", diff --git a/internal/e2e/rollup/bundle-es5umd_golden.js_ b/internal/e2e/rollup/bundle-es5umd_golden.js_ new file mode 100644 index 0000000000..eb93083c86 --- /dev/null +++ b/internal/e2e/rollup/bundle-es5umd_golden.js_ @@ -0,0 +1,31 @@ +/** + * @license A dummy license banner that goes at the top of the file. + * This is version v1.2.3 + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('some_global_var')) : + typeof define === 'function' && define.amd ? define(['exports', 'some_global_var'], factory) : + (global = global || self, factory(global.bundle = {}, global.runtime_name_of_global_var)); +}(this, function (exports, some_global_var) { + 'use strict'; + var fum = 'Wonderland'; + var hello = 'Hello'; + var name = 'Alice'; + console.log(hello + ", " + name + " in " + fum); + // Test for sequences = false + var A = /** @class */ (function () { + function A() { + } + A.prototype.a = function () { + return document.a; + }; + return A; + }()); + function inline_me() { + return 'abc'; + } + console.error(new A().a(), inline_me(), some_global_var.thing); + exports.A = A; + Object.defineProperty(exports, '__esModule', { value: true }); +})); +//# sourceMappingURL=bundle.umd.js.map diff --git a/internal/e2e/rollup/bundle-min-es5umd_golden.js_ b/internal/e2e/rollup/bundle-min-es5umd_golden.js_ new file mode 100644 index 0000000000..e3180cf133 --- /dev/null +++ b/internal/e2e/rollup/bundle-min-es5umd_golden.js_ @@ -0,0 +1,5 @@ +/** + * @license A dummy license banner that goes at the top of the file. + * This is version v1.2.3 + */ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("some_global_var")):"function"==typeof define&&define.amd?define(["exports","some_global_var"],o):o((e=e||self).bundle={},e.runtime_name_of_global_var)}(this,function(e,o){"use strict";console.log("Hello, Alice in Wonderland");var n=function(){function e(){}return e.prototype.a=function(){return document.a},e}();console.error((new n).a(),"abc",o.thing),e.A=n,Object.defineProperty(e,"__esModule",{value:!0})}); \ No newline at end of file diff --git a/internal/e2e/rollup/outputgroups.spec.js b/internal/e2e/rollup/outputgroups.spec.js index 706321c3d2..48138faeda 100644 --- a/internal/e2e/rollup/outputgroups.spec.js +++ b/internal/e2e/rollup/outputgroups.spec.js @@ -31,4 +31,12 @@ describe('outputgroups', () => { checkExists('bundle.umd.js'); checkExists('bundle.umd.js.map'); }); + it('should produce a umd_min sourcemap', () => { + checkExists('bundle.min.umd.js'); + checkExists('bundle.min.umd.js.map'); + }); + it('should produce a es5_umd_min sourcemap', () => { + checkExists('bundle.min.es5umd.js'); + checkExists('bundle.min.es5umd.js.map'); + }); }); diff --git a/internal/e2e/rollup/rollup.spec.js b/internal/e2e/rollup/rollup.spec.js index 8e36670b5f..745765254a 100644 --- a/internal/e2e/rollup/rollup.spec.js +++ b/internal/e2e/rollup/rollup.spec.js @@ -19,4 +19,10 @@ describe('bundling', () => { it('should produce a CJS bundle', () => { check(path, 'bundle.cjs.js', 'bundle-cjs_golden.js_'); }); + it('should produce an es5 UMD bundle', () => { + check(path, 'bundle.es5umd.js', 'bundle-es5umd_golden.js_'); + }); + it('should produce an es5 minified UMD bundle', () => { + check(path, 'bundle.min.es5umd.js', 'bundle-min-es5umd_golden.js_'); + }); }); diff --git a/internal/rollup/rollup_bundle.bzl b/internal/rollup/rollup_bundle.bzl index 60eeab3f78..b5f9c4a6fb 100644 --- a/internal/rollup/rollup_bundle.bzl +++ b/internal/rollup/rollup_bundle.bzl @@ -458,7 +458,10 @@ 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_umd_min) _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( @@ -498,10 +501,16 @@ def _rollup_bundle(ctx): _run_tsc(ctx, ctx.outputs.build_es2015, ctx.outputs.build_es5) es5_min_map = run_terser(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min) es5_min_debug_map = run_terser(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug, debug = True) + cjs_rollup_config = write_rollup_config(ctx, filename = "_%s_cjs.rollup.conf.js", output_format = "cjs") 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) + umd_min_map = run_terser(ctx, ctx.outputs.build_umd, ctx.outputs.build_umd_min, config_name = ctx.label.name + "umd_min", in_source_map = umd_map) + _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] @@ -513,7 +522,10 @@ 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]), + umd_min = depset([ctx.outputs.build_umd_min, umd_min_map]), ) return [ @@ -711,7 +723,10 @@ 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", + "build_umd_min": "%{name}.min.umd.js", "explore_html": "%{name}.explore.html", }