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.

Function calls are not supported in decorators while ng build --prod (AOT)

See original GitHub issue

Type of Issue

[x ] Bug Report
[ ] Feature Request

Description

I’m using your package to build my library to be compiled to js. I’ve compiled everything without any problems, but when I’ll want to consume my library with ng build --prod (AOT enabled), I’m getting error: ERROR in Error during template compile of 'AppModule' Function calls are not supported in decorators but 'BsDropdownModule' was called. ng --prod --aot=false won’t produce any errors.

How To Reproduce

Create new project in Angular, create another module, in this module make forRoot method and post there some things, then pack whole package, and consume in second project. In second project import your module and use on it forRoot method.

Or simply: Download repo: https://github.com/Bloodcast69/aot-error , type npm install and ng build --prod.

Expected Behaviour

Want to build with AOT without errors (I need this to be compatible with Angular Universal)

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr: 2.4.1
@angular/*: 5.2.9
typescript: 2.5.3
rxjs: 5.5.6
node: 8.1.0
npm/yarn: npm: 5.6.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:34
  • Comments:26 (12 by maintainers)

github_iconTop GitHub Comments

10reactions
Bloodcast69commented, Mar 28, 2018

I’ve fixed this. My problem was: I was importing some providers only from folder, not from file directly. For example: This was bad import { SampleService } from './services' This is good import { SampleService } from './services/sample.service'

6reactions
tashoecraftcommented, Apr 11, 2018

Seeing this issue as well, but not for including packages I wrote. Issues are @ngrx/store, @ngrx/effects and TranslateModule. Which all required you to do .forFeature/forChild().

This also all appeared when I upgraded to “ng-packagr”: “2.4.2”, which I also upgraded to angular 6.0.0.rc-3. Few other apps I upgraded and didn’t have an issue so my guess is it’s something with ng-packagr.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving AOT Error in NgRx: Function calls are not supported in ...
When you run ng serve , there is no problem. However when you build the Angular project using prod mode (AOT by default)...
Read more >
Function calls are not supported in decorators while ng build
It's a problem with AOT: the forRoot function needs to be executed at compile-time. On a more recent version of Angular it should...
Read more >
AOT metadata errors - Angular
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 >
Error in prod build :Function calls are not supported in ...
Hello, I'm getting the following error "ng build --prod" ERROR in Error during template compile of 'MainModule' Function calls are not ...
Read more >
Function calls are not supported in decorators but '' was called
Similar code works fire with another Ionic 5 Angular 9 project I created. Is this an Angular 10 issue or a typescript issue?...
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