提交 d1150f0f 编写于 作者: D DCloud_LXH

chore: 编译到小程序插件,解决挂载全局方法防止冲突

上级 16d1ce3c
......@@ -171,7 +171,7 @@ module.exports = {
if (process.env.UNI_MP_PLUGIN) {
// 小程序插件入口使用
// packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire
beforeCode += 'wx.__webpack_require__ = __webpack_require__;'
beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__ = __webpack_require__;`
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
if (UNI_MP_PLUGIN_MAIN) {
......
......@@ -80,7 +80,7 @@ function addMPPluginRequire (compilation) {
const newlineIndex = compilation.assets[name].source().lastIndexOf('\n')
const source = compilation.assets[name].source().substring(0, newlineIndex) +
`\nmodule.exports = wx.__webpack_require__(${uniModuleId});\n` +
`\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__(${uniModuleId});\n` +
compilation.assets[name].source().substring(newlineIndex + 1)
compilation.assets[name] = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册