[AoT] Function calls are not supported in decorators
See original GitHub issueType of Issue
[X] Bug Report
[ ] Feature Request
Description
When running the build, I receive this error:
BUILD ERROR
Error during template compile of 'NgxsRouterPluginModule'
Function calls are not supported in decorators but 'NgxsModule' was called.
Error: Error during template compile of 'NgxsRouterPluginModule'
Function calls are not supported in decorators but 'NgxsModule' was called.
at Object.<anonymous> (/Users/austin/dev/ngxs/node_modules/src/lib/ngc/compile-source-files.ts:66:27)
at Generator.next (<anonymous>)
at /Users/austin/dev/ngxs/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/austin/dev/ngxs/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (/Users/austin/dev/ngxs/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
at Object.<anonymous> (/Users/austin/dev/ngxs/node_modules/src/lib/ng-v5/entry-point/ts/compile-ngc.transform.ts:36:35)
at Generator.next (<anonymous>)
at /Users/austin/dev/ngxs/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)
You can clone this PR and reproduce it: https://github.com/ngxs/store/pull/287
In this use case, we have a module that provides a forRoot
implementation being used in another module that provides a forRoot
.
@NgModule({
imports: [NgxsModule.forFeature([RouterState])]
})
export class NgxsRouterPluginModule {
static forRoot(options?: NgxsRouterPluginOptions): ModuleWithProviders {
return {
ngModule: NgxsRouterPluginModule,
providers: [
{
provide: USER_OPTIONS,
useValue: options
},
{
provide: NGXS_ROUTER_PLUGIN_OPTIONS,
useFactory: routerOptionsFactory,
deps: [USER_OPTIONS]
},
{
provide: RouterStateSerializer,
useClass: DefaultRouterStateSerializer
}
]
};
}
}
If you remove imports: [NgxsModule.forFeature([RouterState])]
it works fine but with it it throws the error. This code compiles fine with just plain ngc.
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 2.4.2
@angular/*:6.rc3
typescript: 2.72
rxjs: 6rc2
node: 8x
npm/yarn: x5x
Please include all version numbers that might be relevant, e.g. third-party libraries
Issue Analytics
- State:
- Created 5 years ago
- Reactions:13
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Solving AOT Error in NgRx: Function calls are not ...
Function calls are not supported in decorators but 'createAction' was called in 'reducers'. The core explanation for this error is well-covered in the ......
Read more >How to get rid of Function calls are not supported in ...
I get the following error: ERROR in Error during template compile of 'AppModule' Function calls are not supported in decorators but ' ...
Read more >Function calls are not supported in decorators but ...
I wrote an angular logger library with ng-packagr to use this in different angular applications. The library doesn't do much more than printing ......
Read more >AOT metadata errors
Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function. The compiler does not currently...
Read more >Function calls are not supported in decorators but '' was called
I have created an Ionic 5 Angular 10 project and I am importing some animations as I have done for previous projects.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For those who use symlink, this issue is related to that. This is a completely unrelated error message.
We removed the node_modules folder under the linked folder and it works now.
If you wonder how can we develop without node_modules under a linked pacakge,then read about preserveSymlinks attribute in angular.json
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
This action has been performed automatically by a bot.