Angular-cli: Broken support for async/await

Created on 16 Sep 2019  路  8Comments  路  Source: angular/angular-cli

馃悶 bug report

Affected Package

@angular-devkit/build-angular > 0.802.2

Is this a regression?

yes

Description

When building with target es2017 using @angular-devkit/build-angular 0.802.2, async/await functions work without problems. When using higher versions, they are surrounded with regeneratorRuntime, which is undefined. When changing target to es2015, async/await gets transformed to yield.

馃敩 Minimal Reproduction

Build https://angular-issue-repro2-vbhzdn.stackblitz.io with described cases.

馃敟 Exception or Error


Uncaught ReferenceError: regeneratorRuntime is not defined

馃實 Your Environment

Angular Version:




Angular CLI: 8.3.4
Node: 12.10.0
OS: linux x64
Angular: 8.2.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.4
@angular-devkit/build-angular     0.803.4
@angular-devkit/build-optimizer   0.803.4
@angular-devkit/build-webpack     0.803.4
@angular-devkit/core              8.3.4
@angular-devkit/schematics        8.3.4
@angular/cdk                      8.2.0
@angular/cli                      8.3.4
@angular/pwa                      0.803.4
@ngtools/webpack                  8.3.4
@schematics/angular               8.3.4
@schematics/update                0.803.4
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.39.2
devkibuild-angular low regression bufix

All 8 comments

zone.js does not support native async/await. Using anything above ES2015 for TypeScript is not recommended and will most likely cause failures or unexpected behavior at runtime.

The set of browsers that fully support ES2017 and that support module scripts are also not identical. Depending on the features used within the application, the application may not work on newer browsers.

Can you give concrete reasons why using anything above es2015 is not recommended for TS? It does officially support every target above.

That issue is about zone.js, which I am aware of and which is not related to TS at all. Regardless, it's not related to this issue too - if @angular-devkit/build-angular supported async in previous versions, it should support it too in current. If it wishes to use regeneratorRuntime anyway, it should make it available, rather than crashing the app at runtime.

Yes. This is indeed a defect. However, even with a fix it will still result in an application that will most likely not function properly both in regard to zone.js and browsers with partial (or broken) ES2017 support that also support module scripts.

If the application will only be targeting browsers that have full ES2017 support then the browserslist file within the project can be updated to reflect the list of browsers the application is required to support. This will also solve the original issue by preventing unnecessary processing of the output scripts.

Fortunately the zone.js and browser compatibility issues are handled in my project. The only thing causing problems is this bug.

Then a browserslist file configured to represent the requirements of the project would be the ideal solution (even when the defect is corrected).

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

ericel picture ericel  路  3Comments

rwillmer picture rwillmer  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments