Skip to content

ngtools/webpack Function expressions are not supported in decorators in 'NgModule' #9464

@crowmagnumb

Description

@crowmagnumb

Versions

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 /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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions