提交 479b92ec 编写于 作者: D DCloud_LXH

fix(mp-plugin): find moduleId

上级 5077e0fc
......@@ -65,7 +65,12 @@ function addMPPluginRequire (compilation) {
const orignalSource = compilation.getAsset(name).source.source()
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'
const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name))
const uniModule = modules.find(module => module.resource && normalizePath(module.resource) === filePath)
let uniModule = modules.find(module => module.resource && normalizePath(module.resource) === filePath)
if (!uniModule && webpack.version[0] > 4) {
uniModule = modules.find(module =>
module.rootModule && module.rootModule.resource && normalizePath(module.rootModule.resource) === filePath
)
}
const uniModuleId = getModuleId(compilation, uniModule)
const source = orignalSource + `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册