By following this article I tried to dynamically import modules to my AppModule according to the environment I'm running (e.g. I only want StoreDevtoolsModule
in dev, not in production).
My approach was
let devImports = [
StoreDevtoolsModule.instrument({maxAge: 25}),
];
if (environment.production) {
devImports = [];
}
@NgModule({
...
imports: [
// other imports
...devImports,
],
...
})
export class AppModule {
}
And it worked when running ng s
, but then I tried running with AOT to check if it works as well with
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng s --aot
and it didn't, StoreDevtoolsModule
was imported and I was able to use the extension to see my app state.
I can understand why AOT fails to dynamically import modules, but is there another way? I have this article with different approach to try yet, but I don't know if it works for that compilation approach.
(I know I can logOnly: environment.production
for StoreDevtoolsModule
, it was just an example)
Thanks.