提交 239f5112 编写于 作者: Q qiang

fix: clone babelLoader to use dynamicImport plugin

上级 4701eb2b
......@@ -125,12 +125,21 @@ module.exports = function (content, map) {
usingComponents[name] = `/${source}`
})
const babelLoader = findBabelLoader(this.loaders)
let babelLoader = findBabelLoader(this.loaders)
if (!babelLoader) {
callback(new Error(uniI18n.__('mpLoader.findFail', {
0: 'babel-loader'
})), content)
} else {
const webpack = require('webpack')
if (webpack.version[0] > 4) {
// clone babelLoader and options
const index = this.loaders.indexOf(babelLoader)
const newBabelLoader = Object.assign({}, babelLoader)
Object.assign(newBabelLoader, { options: Object.assign({}, babelLoader.options) })
this.loaders.splice(index, 1, newBabelLoader)
babelLoader = newBabelLoader
}
addDynamicImport(babelLoader, resourcePath, dynamicImports)
updateUsingComponents(resourcePath, usingComponents, type)
......@@ -139,4 +148,4 @@ module.exports = function (content, map) {
}, err => {
callback(err, content, map)
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册