Skip to content

build optimizer problem with enum #7613

@alexfung888

Description

@alexfung888

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.0-rc.2
node: 8.4.0
os: win32 x64
@angular/animations: 4.4.0-RC.0
@angular/cdk: 2.0.0-beta.10
@angular/common: 4.4.0-RC.0
@angular/compiler: 4.4.0-RC.0
@angular/compiler-cli: 4.4.0-RC.0
@angular/core: 4.4.0-RC.0
@angular/flex-layout: 2.0.0-beta.9
@angular/forms: 4.4.0-RC.0
@angular/http: 4.4.0-RC.0
@angular/material: 2.0.0-beta.10
@angular/platform-browser: 4.4.0-RC.0
@angular/platform-browser-dynamic: 4.4.0-RC.0
@angular/platform-server: 4.4.0-RC.0
@angular/router: 4.4.0-RC.0
@angular/cli: 1.4.0-rc.2
typescript: 2.5.2

Repro steps.

Sorry I can't really reproduce the problem. The same code built several times doesn't even result in the same crash.
What is consisent is:

  1. it only crashes when build-optimizer is enabled during build
  2. it never has problems during ng serve
  3. it always crashes at a reference to an enum:

export enum ICommand { show, hide }
command.next(ICommand.show);

error is "cannot read properly show of undefined"
I have seen several different lines from several components. But always when a enum value is referenced, similar to the line above.

The log given by the failure.

normally it is as above, but once I even got:

bootstrap 6c304fd47c63140fc3b0:54 Uncaught TypeError: Cannot read property 'call' of undefined
at webpack_require (bootstrap 6c304fd47c63140fc3b0:54)
at Object.../../../../../src/main.ts (index.ngfactory.ts:2882)
at webpack_require (bootstrap 6c304fd47c63140fc3b0:54)
at Object.0 (index.ngfactory.ts:3190)
at webpack_require (bootstrap 6c304fd47c63140fc3b0:54)
at webpackJsonpCallback (bootstrap 6c304fd47c63140fc3b0:25)
at main.bundle.js:1

and again, it goes away when the optimiser paramter is removed.

Desired functionality.

the ordinal value should be returned

Mention any other details that might be useful.

I hope I can create a small repo that demonstrates the effect, and I wonder if other people has run into it.

I have turned on build-optimizer since it was introduced. My code hasn't changed much. The lines related to the enum definitely haven't changed for a long time. I have the impression that the crashes start to appear with CLI 1.4.0. I am still experimenting with different version.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulneeds: investigationRequires some digging to determine if action is neededneeds: repro stepsWe cannot reproduce the issue with the information giventype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions