ngtools/webpack Function expressions are not supported in decorators in 'NgModule'
See original GitHub issueVersions
npm 4.2.0
macOS Sierra
@angular/compiler-cli: ^5.2.1
Repro steps
To recreate, clone this repo and then do the following…
cd <repoDir>
git checkout functions
cd module
yarn install
cd ../app
yarn install
yarn run build:prod
Observed behavior
Upon compiling with the last statement I get …
ERROR in ../module/src/utils/module.ts(5,2): Error during template compile of 'Utils'
Function expressions are not supported in decorators in 'NgModule'
'NgModule' contains the error at @angular/core/core.ts(194,31)
Consider changing the function expression into an exported function.
But doing yarn run build:dev
which does not use AoT compilation works fine. You can point your browser to <repoDir>/app/public/index.html to see the results.
Desired behavior
To be able to use AoT compilation with this setup.
Mention any other details that might be useful (optional)
Notice that the tsconfig.json file has a path set to look for code in the modules directory. Not entirely sure if it’s due to that or not but I have multiple apps sharing code from a large base that I have not made into modules due to other issues.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Function expressions are not supported in decorators
In my case error was caused by: export const listAnimation = ()... instead of: export function listAnimation()...
Read more >Solving AOT Error in NgRx: Function calls are not supported in ...
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 >Do you know how Angular transforms your code? - inDepth.dev
Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function.
Read more >Ahead-of-time (AOT) compilation - Angular
The AOT compiler does not support function expressions and arrow functions, also called lambda functions. Consider the following component decorator:.
Read more >angular_ty41232X32的博客-CSDN博客
... property.,ionic4+angular8+动态设置首页,Function expressions are not supported in decorators changing the function ... exported function.,angular,ionic.
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 Free
Top 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
Did you even look at my repo? Did you assume I did absolutely no homework on this? I don’t think the case I have is any of those outlined in any of the links above. Sorry, but I spent a great amount of time reducing my problem to a very simple repo for you to look at and I feel like I was completely dismissed out of hand.
Thank you @filipesilva! I think you and @devoto13 may be right that it has to do with my home-grown sub-module setup which up until the very latest version of Angular, namely 5.2 (been doing it this way since Angular 1.3!), has worked just fine. But now I’ve run into this this problem as well that looks to also be related to this. My actual module is huge and I had a ton of problems getting it to work with ng-packagr a number of months ago. While I might attempt that again, yarn workspaces also looks like a great possible solution. I’ll give those a go. Thank you!