2

I just updated an Angular 7 app to the latest version (8.0.2) following the steps of this guide:

https://update.angular.io/#7.0:8.0

As the last step indicates, I've replaced the way I load lazy modules using the new syntax:

FROM:

loadChildren: "./modules/fwc-policy/fwc-policy.module#FwcPolicyModule"

TO:

loadChildren: () => import('./modules/fwc-policy/fwc-policy.module').then(m => m.FwcPolicyModule)

But now, when I try to compile the application I get this error:

ERROR in src/app/modules/fwc-dashboard/fwc-dashboard.routes.ts(42,31): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.

After googling a bit, I added the option "module": "esNext" to the tsconfig.json file, but the error remains. Do I need to change anything else to make it work?

Thanks in advance,

Fel
  • 4,428
  • 9
  • 43
  • 94
  • Actually, I did upgrade for my app from ng 7 to ng 8 and got the issue, the change of tsconfig.json that you mentioned is just enough, are you sure that config is not overridden and did take the change? have you restarted the app and make sure it is killed first? – Al-Mothafar Jun 26 '19 at 10:35
  • Hi, to make sure, I closed the IDE and ran `npm start` from the command line and I got the same error... I changed the `target` option from `es6` to `esNext` to see what happens and I got another error: `WARNING: Zone.js does not support native async/await in ES2017.`. – Fel Jun 26 '19 at 10:44
  • what your `target` inside tsconfig, try `"target": "es2015"` – Al-Mothafar Jun 26 '19 at 10:49
  • 1
    I'm already explain [here](https://stackoverflow.com/questions/56375703/angular-8-lazy-loading-modules-error-ts1323-dynamic-import-is-only-supporte/56375852#56375852) – Tony Ngo Jun 26 '19 at 10:55

1 Answers1

2

The problem was that the module option was being overriden in file tsconfig.app.json to es2015. After changing it to esNext, it compiles fine now.

Cheers!

Fel
  • 4,428
  • 9
  • 43
  • 94