angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

--aot : "Unexpected Value in imported module. Please add a @NgModule annotation"

Open AntonyJos opened this issue 6 years ago β€’ 2 comments

🐞 Bug report

Command (mark with an x)

  • [ ] new
  • [ ] build
  • [x] serve
  • [ ] test
  • [ ] e2e
  • [ ] generate
  • [ ] add
  • [ ] update
  • [ ] lint
  • [ ] xi18n
  • [ ] run
  • [ ] config
  • [ ] help
  • [ ] version
  • [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: v 5.2.11

Description

Application serves well when --aot is not enabled. But on enabling aot, the compiler seems to throw an error requesting to add the @NgModule annotation. The issue seems to point out to one of the external modules imported.

πŸ”¬ Minimal Reproduction

Have Created a GitHub repository for minimal reproduction of the issue.

  1. Clone the repository from https://github.com/AntonyJos/angularIssue.git
  2. Run npm install
  3. Execute ng serve. Navigate to http://localhost:4200/. Everything works fine.
  4. Execute ng serve --aot.
  5. Application Fails to compile

Expecting the application to be compiled successfully as was the case with JIT

πŸ”₯ Exception or Error




ERROR in : Unexpected value 'Module name in D:/angularIssue/node_modules/....d.ts' imported by the module 'AppModule in D:/angularIssue/src/app/app.module.ts'. Please add a @NgModule annotation.

🌍 Your Environment





     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.1.3
Node: 10.16.3
OS: win32 x64
Angular: 8.1.3
... cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.3
@angular-devkit/build-angular     0.801.3
@angular-devkit/build-optimizer   0.801.3
@angular-devkit/build-webpack     0.801.3
@angular-devkit/core              8.1.3
@angular-devkit/schematics        8.1.3
@ngtools/webpack                  8.1.3
@schematics/angular               8.1.3
@schematics/update                0.801.3
rxjs                              6.5.3
typescript                        3.4.5
webpack                           4.35.2

AntonyJos avatar Dec 18 '19 10:12 AntonyJos

Hi, this seems to be caused by @kyma which is not packaged properly and doesn't confirm with the APF spec. Also, it includes direct dependencies instead of peerDependencies on @angular/ packages which is discouraged as the library can get a different Angular module instead, which would cause your application to break.

More details on how to create a library can be found here: https://angular.io/guide/creating-libraries https://angular.io/guide/creating-libraries#use-typescript-path-mapping-for-peer-dependencies

alan-agius4 avatar Dec 27 '19 09:12 alan-agius4

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.