I'm using webpack (v3.5.6) for building (bundling and compiling) a web application. In our main entry we (try to) lazy load another entry file, using this syntax:
import(/* webpackChunkName: 'charts' */ './charts').then((module) => { /* do something with module */});
With these entries defined:
entry: {
'charts' : [`src/charts.ts`],
'main' : [`src/main.ts`]
},
When webpack does its thing, it generates both entries but the main entry also contains the charts
entry (plus all its imports).
In the webpack config, I have defined:
new webpack.optimize.CommonsChunkPlugin({
names: ['charts'],
minChunks: Infinity,
async: true
})
Anyone got an idea why the main.js output also contains the charts bundle?
Turns out, this was not caused by webpack but by the way our Typescript config had set
module
tocommonjs
instead ofes2015
oramd
.