Skip to content

ng build/serve --target=production fails to load components from CoreModule #5245

Closed
@ukaaa

Description

@ukaaa

Possibly related to #5098

OS

Windows 10

Versions

@angular/cli: 1.0.0-rc.1
node: 6.9.0
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

Repro steps

CoreModule has a couple of components in the declarations array and in the exports array. CoreModule is imported into AppModule.

ng serve --environment=prod --target=production

The log given by the failure

The build fails. All components declared in CoreModule cannot be found:

ERROR in Template parse errors:
'app-header' is not a known element:
1. If 'app-header' is an Angular component, then verify that it is part of this module.
2. If 'app-header' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<app-header></app-header>

Finally it says

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\{project-name}\src'
 @ ./src/main.ts 4:0-74
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.

Other details that might be useful.

The build errors only occur when when the --target flag is set to production or when I call ng serve --prod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions