question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AoT] Function calls are not supported in decorators

See original GitHub issue

Type 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:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tabarehcommented, Aug 24, 2018

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

0reactions
github-actions[bot]commented, Sep 28, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found