-
Notifications
You must be signed in to change notification settings - Fork 155
Build Optimizer does not support es2015 code #816
Comments
Should also support ES2015 code (really, it should support esnext) |
I was under the impression UglifyES (or whatever NG version of uglify) was doing a proper job at DCE on ES2015 code and that we wouldn't need build optimizer for those. |
Note: now we have Angular Elements, support for ES2015 becomes more important, because transpiling custom elements to ES5 is not supported by the standard and produces an error. |
With all the respect, this is a very basic bug and one that should be avoided. You create an Angular 6 application, without changing anything, with all the default settings, build it for production, and it does not work. It is very serious that something so trivial as publishing in production is not working in the final version. More testing is needed, especially for the most important and essential tasks. |
@rafaelfgx - nobody should be using es2015 modules in production, Webpack doesn’t export them, and they’re not turned on by default. |
While buildOptimizer is turned on by default, es6 is not, including the docs: |
@hansl It does not seem to be the case. Here is ES2015 with build optimizer on (fails with angular/angular-cli#10658): Here is ES2015 with build optimizer off: As you can see it is ~200k less with build optimizer enabled. Not sure if it is real gain or a side effect of build optimizer removing not dead code, but this looks like a lot of gain. Most of it comes from Angular packages (~180k). |
Hmm, I see a build optimiser bug for production builds with ES5. See angular/angular-cli#7799 (comment). As a work-around, I switched off build-optimiser and the app is working. |
I got same issues here. |
@robwormald You may want to align with @StephenFluin on your community messaging around enabling ES2015. 😅 https://twitter.com/stephenfluin/status/997224523610116096 P.S. Big fans of all the work you do and are doing! 🤞for production ES2015 support by 2020. |
@byrondover ES2015 syntax (classes, const,let,etc) is fine (assuming your browser target supports it) - lots of good wins to be had there. ES2015 modules, not so much (though if you a very adventurous, no harm trying) |
My talk was about how Angular is working to push the limits of the web, and that if/when it made sense to ship all apps as ES2015 we could do that for you and save a bunch of bundle size and increase perf. Hello World worked for me but in general shipping ES2015 actually can hurt your machine readability as things like the Google crawler don't support ES2015 |
Wow, didn't expect a response, let alone over Memorial Day weekend. 🇺🇸 Thanks for the clarification, gents! 🙇 |
Having this problem since NG 6.0. Still a problem in 6.0.3 along with the latest CLI. As said by this others, setting "buildOptimizer":false will make things in production work again, however, the bundle is apparently too big. Let's see if 6.0.4 will has this fixed? |
@StephenFluin Having our webapp crawlable is not mandatory for many of us. In my company 90% of Angular apps we develop are not publicly available. @robwormald Is it possible to build with only ES2015 syntax ? |
#981 has some fixes for ES2015 code support. Thinking more about it, I don't think we do anything in regards to ES2015 modules in Build Optimizer, so that is probably enough. |
… functions inside arrow functions Partially address #816.
Building upon #981, we should also wrap static initializers on ES2015 classes. This is similar to https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_optimizer/README.md#wrap-enums. The following TS class:
transpiled to es2015 is:
and ran through build optimizer yields:
|
Two potential downsides to this approach would be increased code size and a potential decrease in runtime performance. Both of these should be analyzed to ensure the additional behavior is a net positive. |
… functions inside arrow functions Partially address #816.
As of Angular CLI 6.0.7, the problem is still there. |
@zijianhuang the changes are not in 6.0.7. I think you can test these changes by installing |
I updated @Angular-devkit to 0.6.7 and the issue seems to be gone.
|
issue still here with 0.7.0 and target es6. What would be really nice is an error at compilation time as to maybe find a temporary fix for the part of the code that's problematic. |
@cedvdb can you put up a repro I can look at please? |
… functions inside classes Partially address angular/devkit#816. Supersedes angular/devkit#237
… functions inside arrow functions Partially address angular/devkit#816.
… functions inside classes Partially address angular/devkit#816. Supersedes angular/devkit#237
… functions inside arrow functions Partially address angular/devkit#816.
… functions inside classes Partially address angular/devkit#816. Supersedes angular/devkit#237
… functions inside arrow functions Partially address angular/devkit#816.
The problem seems to be resolved. I didn't manage to reproduce it yet. If you need so I could dig deeper this evening, right now I gotta work. |
As long as it's working, I think there's no need to look further. If I had to bet it wasn't working because at some point you were in an old version. This fix is only on You can check what version you have with |
thank you for this, it's the first time i'm hearing of it. unfortunately except for discussions about this being an issue i can't find anywhere a discussion about the status to fix this. |
This issue was moved to angular/angular-cli#12112 |
Build Optimizer does not currently support es2015
modulescode, but we should support it.Related to #237
The text was updated successfully, but these errors were encountered: