Skip to content

CLI Build Optimization removes namespace export from third party library #10902

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

Closed
pfeigl opened this issue May 17, 2018 · 2 comments
Closed
Labels
freq1: low Only reported by a handful of users who observe it rarely severity3: broken

Comments

@pfeigl
Copy link

pfeigl commented May 17, 2018

Versions

Angular CLI: 6.0.3
Node: 8.11.1
OS: win32 x64
Angular: 6.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.3
@angular-devkit/build-angular     0.6.3
@angular-devkit/build-optimizer   0.6.3
@angular-devkit/core              0.6.3
@angular-devkit/schematics        0.6.3
@angular/cdk                      6.0.0
@angular/cli                      6.0.3
@angular/flex-layout              6.0.0-beta.15
@angular/material                 6.0.0
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.3
@schematics/angular               0.6.3
@schematics/update                0.6.3
ng-packagr                        3.0.0-rc.5
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.8.3

Repro steps

  • Build a library with the following export
export namespace Claims {
    export class Users {
        public static readonly Manage = "Users.Manage";
    }
}
  • Results in the following JS
    /**
     * @fileoverview added by tsickle
     * @suppress {checkTypes} checked by tsc
     */
    (function (Claims) {
        var Users = (function () {
            function Users() {
            }
            Users.Manage = "Users.Manage";
            return Users;
        }());
        Claims.Users = Users;
    })(exports.Claims || (exports.Claims = {}));
  • Create a minimal angular-cli project, consume the library and access the code. Here is how we did it
import { Claims as WebClaims, MenuItem } from "@my/library";

export class AppComponent {
    public menuItems: MenuItem[] = [
        { text: "user-management", icon: "supervisor_account", routerLink: "/users", claims: WebClaims.Users.Manage }
    ];
}

Observed behavior

ERROR TypeError: Cannot read property 'Manage' of undefined
When looking at the optimized build, the complete code for the claims has been gone.

Desired behavior

Required code is not optimized away.

Mention any other details that might be useful (optional)

Has been working on Angular v5, started to not work after Angular has been updated to Angular v6

@filipesilva filipesilva added comp: devkit/build-optimizer freq1: low Only reported by a handful of users who observe it rarely severity3: broken labels May 17, 2018
@filipesilva
Copy link
Contributor

I believe this issue is the same as angular/devkit#934, which was fixed by angular/devkit#959.

@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq1: low Only reported by a handful of users who observe it rarely severity3: broken
Projects
None yet
Development

No branches or pull requests

2 participants