diff --git a/apps/spa/src/main.ts b/apps/spa/src/main.ts index d0b58277..08a06053 100644 --- a/apps/spa/src/main.ts +++ b/apps/spa/src/main.ts @@ -1,6 +1,5 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { AppModule } from './app/app.module'; import { DynamicConfig } from './environments/dynamic-config.model'; import { environment } from './environments/environment'; @@ -11,9 +10,9 @@ fetch('./assets/config.json') ...(config as DynamicConfig), ...environment, }); - - platformBrowserDynamic() - .bootstrapModule(AppModule) - // eslint-disable-next-line no-console - .catch((err) => console.error(err)); - }); + }) + // we have to dynamically import the module, so the environment does not get evaluated before the fetch + .then(() => import('./app/app.module')) + .then(({ AppModule }) => platformBrowserDynamic().bootstrapModule(AppModule)) + // eslint-disable-next-line no-console + .catch((err) => console.error(err));