I have a problem with lazy loading and webpack.
There is a video of Sean Larkin showing how easy it is with webpack 4 to create a lazy loaded bundle (Here). But when I t
Dynamic imports are an ES feature, you need to tell TypeScript to transform to ESNext to get import
on the output, just change "module": "commonjs"
to "module": "esnext"
.
Take this code :
export const LoadMe = () => import('./a-module')
"module": "commonjs"
compiles to module.exports.LoadMe = () => require('a-module')
, Webpack can't know if it's dynamic or just a normal require
"module": "esnext"
compiles to export const LoadMe = () => import('a-module')
, Webpack knows it's dynamic because it's a call expression to import