Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular6 and CLI 6.0.7 getting build error for some libraries 'Please add a @NgModule annotation' #11215

Closed
fmpierce opened this issue Jun 12, 2018 · 8 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@fmpierce
Copy link

fmpierce commented Jun 12, 2018

- [x] bug report 
- [ ] feature request

### Area

- [x] devkit
- [ ] schematics


### Versions

Angular CLI: 6.0.7
Node: 8.9.4
OS: darwin x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.7
@angular-devkit/build-angular     0.6.7
@angular-devkit/build-optimizer   0.6.7
@angular-devkit/core              0.6.7
@angular-devkit/schematics        0.6.7
@angular/cli                      6.0.7
@ngtools/webpack                  6.0.7
@schematics/angular               0.6.7
@schematics/update                0.6.7
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.3

macOS (High Sierra)



### Repro steps

npm run build
with script:
"build": "ng build --prod --progress false --source-map  true && gulp build",


### The log given by the failure

ERROR in : Unexpected value 'Ng2SmartTableModule ... Please add a @NgModule annotation.



### Desired functionality

Should build.

This is a problem for multiple node libraries:
akveo/ng2-smart-table#801
willsoto/ng-chartist#198

@fmpierce fmpierce changed the title Angular6 and CLI 6.0.7 getting build error for some libraries Angular6 and CLI 6.0.7 getting build error for some libraries Please add a @NgModule annotation Jun 12, 2018
@fmpierce
Copy link
Author

fmpierce commented Jun 12, 2018

This issue only seems to occur when using the --prod flag in the build script.

When I build using --prod and I use --aot=false --build-optimizer=false it builds fine. This error seems to happen due to aot when the build is converting html and typescript files into javascript.

https://angular.io/guide/aot-compiler

@fmpierce fmpierce changed the title Angular6 and CLI 6.0.7 getting build error for some libraries Please add a @NgModule annotation Angular6 and CLI 6.0.7 getting build error for some libraries 'Please add a @NgModule annotation' Jun 12, 2018
@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jun 13, 2018
@filipesilva
Copy link
Contributor

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@fmpierce
Copy link
Author

fmpierce commented Jun 14, 2018

@filipesilva will do. This is my first bug report on github and I'm swamped at work right now, so it may take me a few days to get to it.

@fmpierce
Copy link
Author

@filipesilva ,

So in the process of making a repo-app, I couldn't get the problem to occur:
akveo/ng2-smart-table#801
version 1.3.3 was giving me this error before, but now it is not. My app builds with
--prod just fine. Go figure...

Sorry for wasting your time. I guess you can close this issue.

@saaivs
Copy link

saaivs commented Jul 4, 2018

Issue still exists and not fixed at least in ng-cli 6.0.9. It's easy to reproduce.
But, probably, the case is exotic. But, personally, I'm not sure.

The problem is in classes re-re-export.

Example:

The code in some library:

File ~/classes/index.ts:
export * from './my-comp-1.compontent'; export * from './my-comp-2.compontent';

File ~/public_api.ts:
export * from './classes' // we can do it, as TypeScript see the ~/classes/index.ts file ...

If we import libaray to application, then everething works fine with ng serve or with ng build --prod --aot=false --build-optimizer=false, but on build with command ng build --prod we getting reported error.

@pasevin
Copy link

pasevin commented Mar 13, 2019

@saaivs have you managed to find a solution for this?

@saaivs
Copy link

saaivs commented Mar 13, 2019

@saaivs have you managed to find a solution for this?

Last year we managed it by using the explicit full path to files. But currently, looks like, it works as expected with recent version of angular-cli.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants