Skip to content

AOT Compiling Error - Function calls are not supported in decorators but 'MetaModule' was called #208

@asithade

Description

@asithade

I'm submitting a ... (check one with "x")

[x] Bug report 

Current behavior
When trying to compile my Angular 9 app with AOT, I'm getting the following error:

ERROR in Error during template compile of 'SharedModule'
  Function calls are not supported in decorators but 'MetaModule' was called.
Unexpected value 'undefined' imported by the module 'SharedModule in /src/app/shared/shared.module.ts'
Can't export value MetaModule in /node_modules/@ngx-meta/core/meta.module.d.ts from SharedModule in /src/app/shared/shared.module.ts as it was neither declared nor imported!
Error during template compile of 'SharedModule'
  Function calls are not supported in decorators but 'MetaModule' was called.
export const metaFactory = (): MetaStaticLoader =>
  new MetaStaticLoader({
    pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
    pageTitleSeparator: ' - ',
    applicationName: 'XYZ',
    defaults: {
      title: 'XYZ',
      description: 'xyz',
    }
  });

@NgModule({
  ...
  imports: [
    MetaModule.forRoot({
      provide: MetaLoader,
      useFactory: metaFactory
    })
  ]
  exports: [
    ...
    MetaModule
  ]
});

When I remove this package from the modules, it is able to compile properly.

Expected/desired behavior
Able to compile with @ngx-meta/core with AOT

Environment

  • Angular version: 9.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions