我有动态导入模块具有共同的依赖关系,我需要带有g.js的common.js(在这个例子中),但它不起作用,我有空的常见。 怎么了? 我希望与g.js相同
index.js
System.import("./d")
.then( (module) => {
});
System.import("./t")
.then( (module) => {
});
t.js
import "./g";
module.exports = {
x: 5
}
d.js
import "./g";
export function message() {
alert("msg")
}
webpack.config.js
module.exports = {
entry: {index: "./index.js"},
context: __dirname,
output: {
filename: "dist/[name].js"
},
resolve: {
modules: [
"bower_components",
path.resolve('./'),
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: `common`,
async: true
})
]
};
答案 0 :(得分:0)
module.exports = {
entry: {index: "./index.js"},
context: __dirname,
output: {
filename: "dist/[name].js"
},
resolve: {
modules: [
"bower_components",
path.resolve('./'),
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
children: true,
async: true,
}))
]
};