Skip to content

Production build remove meta data needed for dynamic compilation #8896

@vijayanandkannan

Description

@vijayanandkannan

We will close this issue if you don't provide the needed information.
For feature requests, delete the form below and describe the requirements and use case.

angular/cli: 1.6.1


Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)

Angular CLI: 1.6.1
Node: 8.2.1
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router, upgrade

@angular/cli: 1.6.1
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

angular-cli - 1.6.1

### Repro steps

I am enclosing the Project that is dynamic loading and lazy loaded.  

When you compile with ng build --prod, it complies the project, but I get the error when l want to load the dynamic module.

### Observed behavior

main.9e6aeb37dd5ba46c064b.bundle.js:1 ERROR Error: No NgModule metadata found for 'function (){}'.
    at t.resolve (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t.getNgModuleMetadata (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t._loadModules (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t._compileModuleAndAllComponents (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t.compileModuleAndAllComponentsSync (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t.compileModuleAndAllComponentsSync (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t.addComponent (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at t.ngAfterContentInit (0.a2f5d473ce6db5a627d2.chunk.js:1)
    at be (main.9e6aeb37dd5ba46c064b.bundle.js:1)
    at main.9e6aeb37dd5ba46c064b.bundle.js:1

### Desired behavior

What would like to see implemented?

I like to see this error go and the dynamic module loaded.

If you use ng serve then it works. The problem is only with prod build.

What is the usecase?
What did you expect to see?

Have some resolutions. Lot of us are affected with this. This is working in Angular 4... Versions.


### Mention any other details that might be useful (optional)

Enclosing the project that you can try out.
[HeroComponent.zip](https://github.com/angular/angular-cli/files/1563617/HeroComponent.zip)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions