Adding NgRx with Nx MFE cause Unable to evaluate this expression statically

239 Views Asked by At

Adding NgRx to the Nx MFE angular application cause the below issue, removing the generated files issue is not there

@NgModule({
  declarations: [AppComponent],
  imports: [
    .........
    StoreModule.forRoot(
      { product: productStateReducer },
      {
        metaReducers: !environment.production ? [] : [],
        runtimeChecks: {
          strictActionImmutability: true,
          strictStateImmutability: true,
        },
      }
    ),
    EffectsModule.forRoot([]),
    !environment.production ? StoreDevtoolsModule.instrument({ maxAge: 25 }) : [],
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

The issue is with !environment.production

    apps/host/src/app/app.module.ts:43:6
    43     !environment.production
            ~~~~~~~~~~~
    Unable to evaluate this expression statically.
  apps/host/src/environments/environment.ts:19:28
    19 export const environment = new EnvironmentImpl();
                                  ~~~~~~~~~~~~~~~~~~~~~
    This syntax is not supported.

Initial setup

nx g @nrwl/angular:ngrx host --module=apps/host/src/app/app.module.ts --root

environment.ts

class EnvironmentImpl {
  production = false;
}
export const environment = new EnvironmentImpl();
0

There are 0 best solutions below