Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for await is not supported when targeting es2018 #21196

Closed
JounQin opened this issue Jun 24, 2021 · 5 comments · Fixed by #21243
Closed

for await is not supported when targeting es2018 #21196

JounQin opened this issue Jun 24, 2021 · 5 comments · Fixed by #21243
Assignees
Labels
Milestone

Comments

@JounQin
Copy link
Contributor

JounQin commented Jun 24, 2021

Bug Report

Affected Package

The issue is caused by package @angular-devkit/build-angular

Is this a regression?

No

Description

As title

Minimal Reproduction

https://github.com/JounQin/test/blob/angular/src/main.ts#L19

Exception or Error


./src/main.ts:18:8 - Error: Module parse failed: Unexpected token (18:8)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js
 * ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
|     console.log(result);
| 
>     for await (const i of [1, 2, 3]) {
|       console.log(i);
|     }

Your Environment

Angular Version:


Angular CLI: 12.0.5
Node: 12.22.1
Package Manager: yarn 1.22.10
OS: darwin x64

Angular: 12.0.5
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.5
@angular-devkit/build-angular   12.0.5
@angular-devkit/core            12.0.5
@angular-devkit/schematics      12.0.5
@schematics/angular             12.0.5
rxjs                            7.1.0

Anything else relevant?

@JoostK JoostK transferred this issue from angular/angular Jun 24, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Jun 25, 2021

@alan-agius4

Browsers support es2018 will support for await, is that possible to not use babel transformer? And webpack 5 supports for await natively.

@alan-agius4
Copy link
Collaborator

await / async need to be downlevelled because there is no easy way to intercept native promises.

See angular/angular#31730 for more context about this.

@alan-agius4
Copy link
Collaborator

Turns out we need to add an additional Babel plugin.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants