Skip to content

[6.0.0 Regression] build-optimizer breaks exports #10655

Closed

Description

@buu700

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.

Activity

  1. aripp commented on May 6, 2018

    @aripp

    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
    
  2. aripp commented on May 8, 2018

    @aripp

    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

  3. leocaseiro commented on May 11, 2018

    @leocaseiro

    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

  4. leocaseiro commented on May 14, 2018

    @leocaseiro
  5. andriykrasnychuk commented on May 21, 2018

    @andriykrasnychuk

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

  6. loribonna commented on May 21, 2018

    @loribonna

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

  7. filipesilva commented on Jun 7, 2018

    @filipesilva
    Contributor

    Does this happen with the 6.1.x betas?

  8. buu700 commented on Jun 7, 2018

    @buu700
    ContributorAuthor

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

  9. buu700 commented on Jun 7, 2018

    @buu700
    ContributorAuthor

    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.

  10. reopened this on Jun 7, 2018
  11. dsoltesz commented on Jun 7, 2018

    @dsoltesz

    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.

  12. buu700 commented on Jun 9, 2018

    @buu700
    ContributorAuthor

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

  13. Leanvitale commented on Aug 16, 2018

    @Leanvitale

    Try for this..

    ng build --prod --optimization=false

  14. zernolo commented on Dec 21, 2018

    @zernolo

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

  15. filipesilva commented on Dec 21, 2018

    @filipesilva
    Contributor

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

  16. angular-automatic-lock-bot commented on Sep 9, 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.

  17. locked and limited conversation to collaborators on Sep 9, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions