From 5fa1c6009ea61bcdf65491f97cc019200bf6f7a7 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Fri, 11 Mar 2022 16:00:10 +0800 Subject: [PATCH] fix(mp-plugin): addMPPluginRequire --- packages/webpack-uni-mp-loader/lib/plugin/index-new.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js index 89371203c8..fdbcb3490d 100644 --- a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js +++ b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js @@ -80,12 +80,8 @@ function addMPPluginRequire (compilation) { const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx' const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name)) const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id - const newlineIndex = orignalSource.lastIndexOf('\n') - const source = - orignalSource.substring(0, newlineIndex) + - `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` + - orignalSource.substring(newlineIndex + 1) + const source = orignalSource + `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` compilation.assets[name] = { size () { -- GitLab