Having a problem when creating package with RouterModule imported in NgModule decorator
See original GitHub issueType of Issue
[x ] Bug Report
[ ] Feature Request
Description
I’m unable to create a package using ng-packagr@v3.0.0-rc.0. Also I’m using the latest angular version .There is a build error i get when I run the packagr. This only happens when I import the RouterModule inside the imports section of the @NgModule decorator. Like so:
@NgModule({ declarations: [ AppComponent ], imports: [ CommonModule, RouterModule.forChild(routes) ], // providers: [ // { // provide: ROUTES, // useValue: routes, // multi: true // }, // { // provide: ANALYZE_FOR_ENTRY_COMPONENTS, // useValue: routes, // provide them here too // multi: true // } // ], }) export class AppModule { }
The error i get is : BUILD ERROR Error during template compile of ‘AppModule’ Function calls are not supported in decorators but ‘RouterModule’ was called.
However, if i add it to through the providers section(commented out), then there is no error and the package is successfully _created.
How To Reproduce
I’ve created a repository containing the full app. Just download, npm install and then run npm run packagr, in order to reproduce the issue. The link to the repo : https://github.com/SoundarDinesh/lib-using-ng-packagr.git
_
Expected Behaviour
The package should be created when adding RouterModule.forChild in the imports section.
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 3.0.0-rc.0
@angular/*: 6.0.0-rc.5
typescript: ~2.7.2
rxjs: 6.0.0-rc.0
node: v8.11.1
Please include all version numbers that might be relevant, e.g. third-party libraries
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (4 by maintainers)
Top GitHub Comments
Update:
The correct solution seems to be:
See: https://github.com/ngxs/store/blob/master/packages/router-plugin/src/router.module.ts
Note:
skipTemplateCodegen: "false"|"true"
impacts the above.