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

[6.0.0 Regression] build-optimizer breaks exports #10655

Closed
buu700 opened this issue May 4, 2018 · 15 comments
Closed

[6.0.0 Regression] build-optimizer breaks exports #10655

buu700 opened this issue May 4, 2018 · 15 comments

Comments

@buu700
Copy link
Contributor

buu700 commented May 4, 2018

Versions

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0
Node: 9.11.1
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

  • git clone https://github.com/buu700/ng6-quill-test.git
  • cd ng6-quill-test
  • npm install .
  • ng serve --prod

This project is a small modification of ng new's output which adds import 'parchment';. The relevant code within the parchment package is as follows:

src/registry.ts:

. . .
export enum Scope {
  . . .
  INLINE_BLOT = INLINE & BLOT, // 0110
  . . .
}
. . .


src/blob/abstract/leaf.ts:

. . .
import * as Registry from '../../registry';

class LeafBlot extends ShadowBlot implements Leaf {
  static scope = Registry.Scope.INLINE_BLOT;
. . .

Observed behavior

Logged to console:

Uncaught TypeError: Cannot read property 'INLINE_BLOT' of undefined

Desired behavior

As when building/serving without --prod, Registry.Scope should be defined.

Mention any other details that might be useful (optional)

Disabling the build optimizer fixes the issue. I didn't run into this with 6.0.0-rc.7, so the regression is from some time between 6.0.0-rc.8 and 6.0.0 final.

@aripp
Copy link

aripp commented May 6, 2018

Yes, that happens here too when I try to start my app that was built with command ng build --base-href /AppPortal/ --prod

I'm using:

Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

@aripp
Copy link

aripp commented May 8, 2018

Setting "buildOptimizer": false in angular.json did fix the problem for me. The bundle size is as small as before the upgrade to Angular 6.

capture

@leocaseiro
Copy link

Thanks @aripp it worked for me too. The bundle is slighter bigger, but works for the time being.

For who wants to test using @angular/elements try my modified version:

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

cc #7799

@leocaseiro
Copy link

See angular/devkit#816

@andriykrasnychuk
Copy link

this workaround worked for me:
export enum YourEnum { Prop1 = 'prop1', Prop2 = 'prop2', }

@loribonna
Copy link

Thanks @andriykrasnychuk for the workaround!
Also i checked that it breaks if there is a cast like Prop3 = <any>'someValue'.

@filipesilva
Copy link
Contributor

Does this happen with the 6.1.x betas?

@buu700
Copy link
Contributor Author

buu700 commented Jun 7, 2018

Nope, just tested and it looks like this is no longer an issue. Specifically, it seems to have been fixed by @angular-devkit/build-optimizer@0.6.1 (the next version after what I'd used here).

@buu700 buu700 closed this as completed Jun 7, 2018
@buu700
Copy link
Contributor Author

buu700 commented Jun 7, 2018

Although, I see that #10983 is using @angular-devkit/build-optimizer@0.6.3, so maybe they're different issues, and/or maybe this repro is insufficient? I'll try again in my actual project some time soon and see if that behaves any differently.

@buu700 buu700 reopened this Jun 7, 2018
@dsoltesz
Copy link

dsoltesz commented Jun 7, 2018

I manually added @angular-devkit/build-optimizer@0.6.8 as dev dependency to package json and issue seems to be resolved with this version.

@buu700
Copy link
Contributor Author

buu700 commented Jun 9, 2018

Can't reproduce the problem in @cyph either after upgrading to 6.1, so I'll close this again.

@buu700 buu700 closed this as completed Jun 9, 2018
@Leanvitale
Copy link

Try for this..

ng build --prod --optimization=false

@zernolo
Copy link

zernolo commented Dec 21, 2018

by this issue, seems that the build-optimizer is not working anymore valor-software/ngx-bootstrap#4948

@filipesilva
Copy link
Contributor

@zernolo can you open a new issue with a reproduction please?

@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants