Skip to content

Build Optimizer does not support es2015 code #12112

Closed

Description

@alexeagle

From @filipesilva on April 30, 2018 17:28

Build Optimizer does not currently support es2015 modules code, but we should support it.

Related to angular/devkit#237

Copied from original issue: angular/devkit#816

Activity

  1. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @robwormald on May 4, 2018 18:43

    Should also support ES2015 code (really, it should support esnext)

  2. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @hansl on May 5, 2018 19:5

    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.

  3. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @cyrilletuzi on May 8, 2018 9:43

    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.

  4. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @rafaelfgx on May 10, 2018 23:59

    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.

  5. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @robwormald on May 11, 2018 0:34

    @rafaelfgx - nobody should be using es2015 modules in production, Webpack doesn’t export them, and they’re not turned on by default.

  6. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @msklvsk on May 11, 2018 9:22

    While buildOptimizer is turned on by default, es6 is not, including the docs:

    image

    (angular.io/guide/typescript-configuration)

  7. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @devoto13 on May 14, 2018 12:24

    @hansl It does not seem to be the case.

    Here is ES2015 with build optimizer on (fails with #10658):

    screenshot 2018-05-14 13 56 39

    Here is ES2015 with build optimizer off:

    screenshot 2018-05-14 14 14 36

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

  8. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @catull on May 16, 2018 12:43

    Hmm, I see a build optimiser bug for production builds with ES5.

    See #7799 (comment).
    That issue is closed, stating that the bug is tracked here.

    As a work-around, I switched off build-optimiser and the app is working.
    With build-optimiser ON, the error is as documented in the "issue comment" at the top of this comment.

  9. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @hijamoya on May 17, 2018 10:17

    I got same issues here.

  10. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @byrondover on May 27, 2018 20:27

    robwormald commented 10 days ago

    @rafaelfgx - nobody should be using es2015 modules in production, Webpack doesn’t export them, and they’re not turned on by default.

    @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. :neckbeard:

  11. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @robwormald on May 27, 2018 20:51

    @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)

  12. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @StephenFluin on May 27, 2018 21:25

    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

  13. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @byrondover on May 27, 2018 21:59

    Wow, didn't expect a response, let alone over Memorial Day weekend. 🇺🇸

    Thanks for the clarification, gents! 🙇

  14. alexeagle commented on Sep 4, 2018

    @alexeagle
    ContributorAuthor

    From @zijianhuang on May 28, 2018 5:29

    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?

  15. 15 remaining items

  16. VVKot commented on Feb 12, 2019

    @VVKot

    @filipesilva Greetings! Does "now" mean angular-cli 8+?

  17. filipesilva commented on Feb 12, 2019

    @filipesilva
    Contributor

    @VVKot it should be in 7.3 too, the latest fixes we had were released in https://github.com/angular/angular-cli/releases/tag/v7.3.0-rc.0.

  18. ryshep111 commented on May 6, 2019

    @ryshep111

    The issue is still present for me on version 7.3.7

  19. filipesilva commented on May 7, 2019

    @filipesilva
    Contributor

    @ryshep111 can you open a new issue including a reproduction? I'm don't really know what you're seeing or how to investigate it.

  20. zijianhuang commented on May 7, 2019

    @zijianhuang

    @ryshep111, the issue was fixed somewhere after v6.0.3, at the moment I am using v7.2.12.
    my tsconfig.json:

    {
    	"compileOnSave": false,
    	"compilerOptions": {
    		"baseUrl": "./",
    		"outDir": "./dist/out-tsc",
    		"sourceMap": true,
    		"declaration": false,
    		"moduleResolution": "node",
    		"emitDecoratorMetadata": true,
    		"experimentalDecorators": true,
    		"target": "es2015",
    		"typeRoots": [
    			"node_modules/@types"
    		],
    		"lib": [
    			"es2017",
    			"dom"
    		],
    		"skipLibCheck": true
    	}
    }

    My angular.json

    ...
    					"configurations": {
    						"production": {
    							"optimization": true,
    							"outputHashing": "all",
    							"sourceMap": false,
    							"extractCss": true,
    							"namedChunks": false,
    							"aot": true,
    							"extractLicenses": true,
    							"vendorChunk": false,
    							"buildOptimizer": true,
    							"fileReplacements": [
    								{
    									"replace": "src/environments/environment.ts",
    									"with": "src/environments/environment.prod.ts"
    								}
    							],
    							"serviceWorker": true
    						}
    					}
    ...

    Hope this gives you some hint.

  21. shlomiassaf commented on May 26, 2019

    @shlomiassaf

    @alan-agius4 @filipesilva

    OK, it took me 4 hours but I think I found the root cause, or at least the way to reproduce exactly.

    I've created a repository to reproduce it, all explanations are in the readme file there.

    https://github.com/shlomiassaf/angular-cli-build-optimizer-es2015-issue

    Ohh boy, this one was tricky.

    TLDR: It will only happen if the class is built in FESM2015 module AND it has a NON-ANGULAR decorator applied on it.

    I.E: Angular packages built with ng-packger.

  22. waterplea commented on Jul 12, 2019

    @waterplea

    @shlomiassaf it reproduces for me too. In our library we have our own decorators so it's probably the same root cause — all our super calls are dropped with build optimizer and es2015 target. Works fine in Angular 8 though. @filipesilva any chance this could be fixed in Angular 7 by investigating the above reproduction repo? Could we at least somehow mark super calls so compiler does not cut them out? This looks like the only problem we are having.

  23. filipesilva commented on Jul 12, 2019

    @filipesilva
    Contributor

    @waterplea I think it got fixed in #14263. In general we don't do releases of n-1 versions unless it's a security concern though. Is there something stopping you for updating to version 8?

  24. waterplea commented on Jul 12, 2019

    @waterplea

    @filipesilva I'm developing a library which theoretically works in Angular 6+, it's just unfortunate that if users would want to run my library in es2015 they are forced to update. So yeah, I understand you not touching older versions, I was maybe hoping for some ninja tactics like // @dynamic or whatever :)

  25. maxim1006 commented on Sep 2, 2019

    @maxim1006

    @VVKot it should be in 7.3 too, the latest fixes we had were released in https://github.com/angular/angular-cli/releases/tag/v7.3.0-rc.0.

    No it is not working in 7.3

  26. maxim1006 commented on Sep 2, 2019

    @maxim1006

    #14263

    Hello

    Why this issue is closed?

    In any v7 version, with ng library, you can reproduce this issue.

    In my company we cant update to v8 instantly.

  27. Stevearzh commented on Sep 27, 2019

    @Stevearzh

    Well, is there something I can do to solve this on v6.2.9? We can't update (trying) to v8 like upstairs.

  28. angular-automatic-lock-bot commented on Oct 28, 2019

    @angular-automatic-lock-bot

    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.

  29. locked and limited conversation to collaborators on Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions