Skip to content

Dual app has duplicate declarations error only with AOT #6189

Closed
@zackarychapple

Description

@zackarychapple
- [x] bug report -> please search issues before submitting

Versions.

@angular/cli: 1.0.2
node: 7.5.0
os: darwin x64
@angular/common: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/forms: 4.1.1
@angular/http: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/router: 4.1.1
@angular/cli: 1.0.2
@angular/compiler-cli: 4.1.1

Repro steps.

I created a repo that replicates this issue.

  1. Create Second app in .angular-cli.json with unique main file.
  2. Create Duplicate of app.module.ts and name it `app2.module.ts
  3. Run ng build everything works as expected
  4. Run ng build --prod --aot and get the below error:

The log given by the failure.

ERROR in Type AppComponent in /Users/zchapple/code/test/src/app/app.component.ts is part of the declarations of 2 modules: AppModule in /Users/zchapple/code/test/src/app/app.module.ts and AppModule in /Users/zchapple/code/test/src/app/app2.module.ts! Please consider moving AppComponent in /Users/zchapple/code/test/src/app/app.component.ts to a higher module that imports AppModule in /Users/zchapple/code/test/src/app/app.module.ts and AppModule in /Users/zchapple/code/test/src/app/app2.module.ts. You can also create a new NgModule that exports and includes AppComponent in /Users/zchapple/code/test/src/app/app.component.ts then import that NgModule in AppModule in /Users/zchapple/code/test/src/app/app.module.ts and AppModule in /Users/zchapple/code/test/src/app/app2.module.ts.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/zchapple/code/test/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

Desired functionality.

Expected behavior is that the apps should be evaluated independently for duplicate module AOT checks.

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