我正在尝试以异步导入 lodash 为例,但它被包含在主块中
Version: webpack 4.23.1
module.exports = {
mode: "development",
context: __dirname,
devtool: 'sourcemap',
entry: {
"entry1": "./src/entry1.ts"
},
output: {
path: __dirname + "/dist",
filename: "[name].js",
chunkFilename: "[name].js",
},
// ...
}
我做了一个简单的代码来重现这个问题
document.addEventListener('DOMContentLoaded', async () => {
console.log('DOMContentLoaded')
// lodash should be made into a separate chunk
// but it gets included in the entry1 chunk
const _ = await import('lodash')
console.log('loaded test chunk')
console.log(_.concat)
})