Skip to content

Commit

Permalink
fix(mp-plugin): addMPPluginRequire
Browse files Browse the repository at this point in the history
  • Loading branch information
StrivingRabbit committed Mar 11, 2022
1 parent 7b5a17f commit 5fa1c60
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/webpack-uni-mp-loader/lib/plugin/index-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 5fa1c60

Please sign in to comment.