fulls1z3 / ngx-meta

Dynamic page title & meta tags utility for Angular (w/server-side rendering)
MIT License
333 stars 47 forks source link

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

Closed asithade closed 3 years ago

asithade commented 4 years ago

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

constantinoschristoforou commented 4 years ago

I have the same issue

williamareynolds commented 4 years ago

Same issue on Angular CLI 9.1.8

Ismaestro commented 4 years ago

Same here with Angular CLI 9.1.10

nishadmenezes commented 4 years ago

I have the same issue too

DennyReM commented 3 years ago

if you use Angular version less then 9 try to install version of package less then 8 ,for my app with v8.2 version 8.0.2 compiled!

asithade commented 3 years ago

I'm seeing the same error again with Angular 11.

enableIvy: false
aot: true

Error during build:

  Function calls are not supported in decorators but 'MetaModule' was called.
Unexpected value 'undefined' imported by the module 'AppModule in /site/src/app/app.module.ts'
Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'MetaModule' was called.

Enabling ivy allows it to compile though

fulls1z3 commented 3 years ago

see https://github.com/fulls1z3/ngx-meta/pull/216