Skip to content

unnecessary asyncToGenerator usage when browser supports native async/await #23546

Closed as not planned
@wratho

Description

@wratho

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

This bug exists in Angular 13 and 14.

Yes, the previous version in which this bug was not present was: ....

Description

When changing from target: "es2020" to target: "es2022" something involving webpack/babel is causing _this to no longer exist. The folks at babel are looking into it (babel/babel#14749), but they requested an open question as to why we are asyncToGenerator at all.

I have forced my browserslist to be 100% supporting native async/await and it still runs this. I also cannot determine any way to force this plugin to not be processed at all.

A clear and concise description of the problem...

🔬 Minimal Reproduction

In Angular 13/14 have a function formatted

nameOfFunction = async () => {
  this.doThing();
}

build this once with a 2020 target and then again with 2022 target and see the difference in the generated code. The 2022 version doesn't have _this. I don't think i expect angular to have a fix for this, unless it is a bug that we are interacting with asyncToGenerator at all.

🔥 Exception or Error





🌍 Your Environment




Angular CLI: 14.0.4
Node: 16.13.2
Package Manager: npm 8.1.2
OS: win32 x64

Angular: 14.0.4
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.4
@angular-devkit/build-angular   14.0.4
@angular-devkit/core            14.0.4
@angular-devkit/schematics      14.0.4
@angular/flex-layout            14.0.0-beta.40
@schematics/angular             14.0.4
rxjs                            7.5.5
typescript                      4.7.4

webpack 5.73
babel: 7.17

Anything else relevant?
I wasn't really sure how to phrase this as a bug, as it's more a question. Please let me know if i need to put this somewhere else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions