-
Notifications
You must be signed in to change notification settings - Fork 12k
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
@angular-devkit/build-angular always includes "@babel/plugin-transform-async-to-generator" and "@babel/plugin-proposal-async-generator-functions" #25708
Comments
Hi, Those plugins are required because |
Hi, thanks for the quick response. Could this then be documented or mentioned somewhere? I tried to google this issue for quite some time, but never found anything pointing towards zone.js being the culprit. |
You're right, the only place where it's stated is here: angular-cli/packages/angular_devkit/build_angular/src/tools/babel/presets/application.ts Lines 241 to 248 in b09ce57
|
Now that you mention it, I've even seen this line of code, but because it is inside an I'm just throwing questions at this point, but I'm curious, sorry 😄 |
The The goal of signals is indeed to allow zoneless apps but we're not there yet (we still need the signal components etc.). But I agree, zoneless apps already exist and could benefit from having that kind of options. I'll reopen to get an "offcial" response from the maintainers. 👍🏻 |
Duplicate of #22191 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When I'm building an Angular project for modern browsers, I expect modern features like
async/await
to be used. However, when building the project, Angular uses Babel to replaceasync/await
with calls to a helper function, which uses generator functions instead.This means, that there is a slight overhead in performance, as well as bundle size to accommodate for the polyfill. Most annoyingly (to me at least) is that debugging can be tough, because I can't properly "step into" an async function call, without landing in Babel's helper function. Which makes understanding the code much harder.
Proposed changes
I think either the behaviour should be well documented (e.g. on the browser support site), or changed/customizable. Most browsers support
async
andawait
, so in my opinion the default should also include those features.Minimal Reproduction
I have created a demo repo for this issue: https://github.com/Simon-Hayden-iteratec/async-await-missing
There is a readme explaining the behaviour and how to reproduce it.
But the gist of it:
ng build --optimization=false --output-hashing=none
targeting only modern browsersdist/<app-name>/main.js
find the function_asyncToGenerator
from Babel. The file will also not include anasync
s orawait
s.I investigated where this code is coming from, and I assume these lines are the cause:
It appears to be
true
for all source files. I assume the line was only intended to be true for Angular library builds (or similar).When I edit the file in my local
node_modules
to be alwaysfalse
, I see a small, but measurable reduction in bundle size (measured withdu -bc "dist/async-await-missing"
in the linked Git repo):However, the difference is larger, for larger projects (tested in a company-private repo).
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: