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.

Error during template compile, function calls are not supported in decorators.

See original GitHub issue

Type of Issue

[X] Bug Report
[ ] Feature Request

Description

One of my libraries dependencies requires a .forRoot() call to declare the module with providers.

I am including this Module.forRoot() in my module and it works fine, however running packagr for the project fails on compilation.

How To Reproduce

import { DeviceDetectorModule } from 'ngx-device-detector';

@NgModule({
    imports: [
        DeviceDetectorModule.forRoot(),
    ],
   ...
}
BUILD ERROR
Error during template compile of 'EasyGridModule'
  Function calls are not supported in decorators but 'DeviceDetectorModule' was called.

Error: Error during template compile of 'EasyGridModule'
  Function calls are not supported in decorators but 'DeviceDetectorModule' was called.

    at Object.<anonymous> (C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ngc\compile-source-files.js:69:35)
    at Generator.next (<anonymous>)
    at C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ngc\compile-source-files.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ngc\compile-source-files.js:3:12)
    at Object.compileSourceFiles (C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ngc\compile-source-files.js:19:12)
    at Object.<anonymous> (C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ng-v5\entry-point\ts\compile-ngc.transform.js:37:60)
    at Generator.next (<anonymous>)
    at C:\Users\Tyler\Documents\GitHub\@ngx-easy\node_modules\ng-packagr\lib\ng-v5\entry-point\ts\compile-ngc.transform.js:7:71
    at new Promise (<anonymous>)

Expected Behaviour

Successful compilation for publishing.

Version Information

    "@angular/compiler-cli": "^6.0.0-rc.1",
    "@angular-devkit/build-ng-packagr": "~0.5.10",
    "@angular-devkit/build-angular": "~0.5.10",
    "ng-packagr": "^2.4.2",
    "tsickle": ">=0.27.5",
    "tslib": "^1.9.0",
    "typescript": "2.7.2",
    "@angular/cli": "~6.0.0-rc.6",

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
dhergescommented, May 6, 2018

preface: I hate tsconfig.

@wardbell ng-packagr auto-generates a tsconfig for build. TL;DR it’s just releasing 3.0.0-rc.3 that enables fullTemplateTypeCheck and should solve your specific build issue

Long story:

$ git clone https://github.com/johnpapa/angular-ngrx-data.git ngrx-data-FAIL
$ cd ngrx-data-FAIL
$ git checkout ng-v6-FAIL
$ npm install
/* edit node_modules/ng-packagr/lib/ts/conf/tsconfig.ngc.json */
$ cat node_modules/ng-packagr/lib/ts/conf/tsconfig.ngc.json 
{
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "flatModuleId": "AUTOGENERATED",
    "flatModuleOutFile": "AUTOGENERATED",
    "skipTemplateCodegen": false,
    "strictMetadataEmit": false,
...
$ npm run build-lib 
...
Build success

The combinations I tried were:

Build success

    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true
    "skipTemplateCodegen": false,
    "strictMetadataEmit": false

Build failures

    "skipTemplateCodegen": false,
    "strictMetadataEmit": true
    // fullTemplateTypeCheck omitted (= default value)
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    // fullTemplateTypeCheck omitted (= default value)
    "skipTemplateCodegen": true,
    "strictMetadataEmit": false,
    // fullTemplateTypeCheck omitted (= default value)
4reactions
alan-agius4commented, Apr 30, 2018

Looks like the @dynamic has no effect in this case. Though what I noticed was that setting fullTemplateTypeCheck does stop the error. I’ll log an error with Angular.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving AOT Error in NgRx: Function calls are not supported in ...
ERROR in src/app/app.module.ts(33,25): Error during template compile of 'AppModule' Function calls are not supported in decorators but 'createAction' was ...
Read more >
ERROR Function calls are not supported in decorators but ...
Error during template compile of 'AppRoutingModule' Function calls are not supported in decorators but 'NativeScriptRouterModule' was called. It ...
Read more >
Building Angular 6 library fails, with a vague error.
Function calls are not supported in decorators but 'ɵmakeDecorator' was called. Error during template compile of 'Injectable'. Function calls are not supported ......
Read more >
Function calls are not supported in decorators but '' was called
Is this an Angular 10 issue or a typescript issue? > Error during template compile of 'AppComponent' Function calls are > not supported...
Read more >
Error in prod build :Function calls are not supported in ...
ERROR in Error during template compile of 'MainModule' Function calls are not supported in decorators but 'InputEditorModule' was called.
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