Skip to content

Angular 12.2: Global async-polyfill is generated when using target es2105 #21551

@dskgry

Description

@dskgry

Which @angular/* package(s) are the source of the bug?

compiler-cli, compiler

Is this a regression?

Yes

Description

Hi,
there seems to be an issue in angular 12.2.0 when generating bundles with typescript target es2015. I was able to reprodue the bug in combination with stencil web components, but I think this could be a general issue.

When async/await is used in the web components, the production bundle generates a global function for polyfilling async/await which is dangerous and broke our production code. This only happens with target es2015. Target es2017 works. Also angular 12.1.5 works as expected.

A minimum example is provided in the link below. This example also contains the compilation outputs for angular 12.2 es2015, es2017 and angular 12.1.5 es2015

Please provide a link to a minimal reproduction of the bug

https://github.com/dskgry/angular12_2_0_issue

Please provide the exception or error you saw

Target ES2015:

// generates this global async polyfill in the bundle
var r = (h, u, e) => new Promise((o, l) => {
    var i = s => {
        try {
            t(e.next(s))
        } catch (n) {
            l(n)
        }
    }, c = s => {
        try {
            t(e.throw(s))
        } catch (n) {
            l(n)
        }
    }, t = s => s.done ? o(s.value) : Promise.resolve(s.value).then(i, c);
    t((e = e.apply(h, u)).next())
});

Please provide the environment you discovered this bug in

Angular CLI: 12.2.0
Node: 14.15.0
Package Manager: npm 7.18.1
OS: windows 10 x64

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions