Angular-cli: [6.0.0 Regression] build-optimizer breaks exports

Created on 5 May 2018  Â·  15Comments  Â·  Source: angular/angular-cli

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.

devkibuild-optimizer medium regression bufix

Most helpful comment

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

All 15 comments

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

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

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 https://github.com/angular/angular-cli/issues/7799

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

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

Does this happen with the 6.1.x betas?

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

Although, I see that #10983 is using @angular-devkit/[email protected], 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.

I manually added @angular-devkit/[email protected] as dev dependency to package json and issue seems to be resolved with this version.

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

Try for this..

ng build --prod --optimization=false

by this issue, seems that the build-optimizer is not working anymore https://github.com/valor-software/ngx-bootstrap/issues/4948

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

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

jmurphzyo picture jmurphzyo  Â·  3Comments

gotschmarcel picture gotschmarcel  Â·  3Comments

brtnshrdr picture brtnshrdr  Â·  3Comments

daBishMan picture daBishMan  Â·  3Comments

ericel picture ericel  Â·  3Comments