Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/didi/mpx
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Jan 31, 2024
2 parents a7c1413 + db51bdd commit 55dc32f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,18 @@ class MpxWebpackPlugin {
if (this.options.writeMode === 'changed') {
const writedFileContentMap = new Map()
const originalWriteFile = compiler.outputFileSystem.writeFile
compiler.outputFileSystem.writeFile = (filePath, content, callback) => {
// fs.writeFile(file, data[, options], callback)
compiler.outputFileSystem.writeFile = (filePath, content, ...args) => {
const lastContent = writedFileContentMap.get(filePath)
if (Buffer.isBuffer(lastContent) ? lastContent.equals(content) : lastContent === content) {
return callback()
const callback = args[args.length - 1]
if (typeof callback === 'function') {
callback()
}
return
}
writedFileContentMap.set(filePath, content)
originalWriteFile(filePath, content, callback)
originalWriteFile(filePath, content, ...args)
}
}

Expand Down Expand Up @@ -1288,7 +1293,7 @@ class MpxWebpackPlugin {
target = expr.object
}

if (!matchCondition(resourcePath, this.options.transMpxRules) || resourcePath.indexOf('@mpxjs') !== -1 || !target || mode === srcMode) return
if (!matchCondition(resourcePath, this.options.transMpxRules) || resourcePath.indexOf('node_modules/@mpxjs') !== -1 || !target || mode === srcMode) return

const type = target.name
const name = type === 'wx' ? 'mpx' : 'createFactory'
Expand Down

0 comments on commit 55dc32f

Please sign in to comment.