build: include tslib in umd bundles (#23354)
Fixes #22971 PR Close #23354
This commit is contained in:
parent
b76dd3b979
commit
2e270bb96a
|
@ -76,7 +76,7 @@ WELL_KNOWN_GLOBALS = { p: _global_name(p) for p in [
|
|||
"rxjs/operators",
|
||||
]}
|
||||
|
||||
def _rollup(ctx, rollup_config, entry_point, inputs, js_output, format = "es", package_name = ""):
|
||||
def _rollup(ctx, rollup_config, entry_point, inputs, js_output, format = "es", package_name = "", include_tslib = False):
|
||||
map_output = ctx.actions.declare_file(js_output.basename + ".map", sibling = js_output)
|
||||
|
||||
args = ctx.actions.args()
|
||||
|
@ -96,7 +96,10 @@ def _rollup(ctx, rollup_config, entry_point, inputs, js_output, format = "es", p
|
|||
|
||||
globals = dict(WELL_KNOWN_GLOBALS, **ctx.attr.globals)
|
||||
args.add("--external")
|
||||
args.add(globals.keys(), join_with=",")
|
||||
external = globals.keys()
|
||||
if not include_tslib:
|
||||
external.append("tslib")
|
||||
args.add(external, join_with=",")
|
||||
|
||||
args.add("--globals")
|
||||
args.add(["%s:%s" % g for g in globals.items()], join_with=",")
|
||||
|
@ -220,7 +223,9 @@ def _ng_package_impl(ctx):
|
|||
fesm2015.append(_rollup(ctx, config, es2015_entry_point, esm_2015_files, fesm2015_output))
|
||||
fesm5.append(_rollup(ctx, config, es5_entry_point, esm5_sources, fesm5_output))
|
||||
|
||||
bundles.append(_rollup(ctx, config, es5_entry_point, esm5_sources, umd_output, format = "umd", package_name = package_name))
|
||||
bundles.append(
|
||||
_rollup(ctx, config, es5_entry_point, esm5_sources, umd_output,
|
||||
format = "umd", package_name = package_name, include_tslib = True))
|
||||
uglify_sourcemap = run_uglify(ctx, umd_output, min_output,
|
||||
config_name = entry_point.replace("/", "_"))
|
||||
bundles.append(struct(js = min_output, map = uglify_sourcemap))
|
||||
|
|
|
@ -178,8 +178,10 @@ describe('@angular/core ng_package', () => {
|
|||
.toMatch(/@license Angular v\d+\.\d+\.\d+(?!-PLACEHOLDER)/);
|
||||
});
|
||||
|
||||
it('should have tslib helpers',
|
||||
() => { expect(shx.cat('bundles/core.umd.js')).not.toContain('undefined.__extends'); });
|
||||
it('should have tslib helpers', () => {
|
||||
expect(shx.cat('bundles/core.umd.js')).toContain('function __extends');
|
||||
expect(shx.cat('bundles/core.umd.js')).not.toContain('undefined.__extends');
|
||||
});
|
||||
it('should have an AMD name',
|
||||
() => { expect(shx.cat('bundles/core.umd.js')).toContain('define(\'@angular/core\''); });
|
||||
it('should define ng global symbols',
|
||||
|
|
|
@ -48,7 +48,7 @@ def ng_module(name, tsconfig = None, entry_point = None, **kwargs):
|
|||
entry_point = "public_api.ts"
|
||||
_ng_module(name = name, flat_module_out_file = name, tsconfig = tsconfig, entry_point = entry_point, **kwargs)
|
||||
|
||||
def ng_package(name, readme_md = None, license_banner = None, globals = {}, **kwargs):
|
||||
def ng_package(name, readme_md = None, license_banner = None, **kwargs):
|
||||
if not readme_md:
|
||||
readme_md = "//packages:README.md"
|
||||
if not license_banner:
|
||||
|
@ -58,9 +58,6 @@ def ng_package(name, readme_md = None, license_banner = None, globals = {}, **kw
|
|||
name = name,
|
||||
readme_md = readme_md,
|
||||
license_banner = license_banner,
|
||||
globals = dict(globals, **{
|
||||
"tslib": "tslib"
|
||||
}),
|
||||
replacements = PKG_GROUP_REPLACEMENTS,
|
||||
**kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue