@mpxjs/webpack-plugin 2.7.31 → 2.7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const harmonySpecifierTag = require('webpack/lib/dependencies/HarmonyImportDepen
|
|
|
12
12
|
const NormalModule = require('webpack/lib/NormalModule')
|
|
13
13
|
const EntryPlugin = require('webpack/lib/EntryPlugin')
|
|
14
14
|
const JavascriptModulesPlugin = require('webpack/lib/javascript/JavascriptModulesPlugin')
|
|
15
|
+
const FlagEntryExportAsUsedPlugin = require('webpack/lib/FlagEntryExportAsUsedPlugin')
|
|
15
16
|
const FileSystemInfo = require('webpack/lib/FileSystemInfo')
|
|
16
17
|
const normalize = require('./utils/normalize')
|
|
17
18
|
const toPosix = require('./utils/to-posix')
|
|
@@ -274,6 +275,9 @@ class MpxWebpackPlugin {
|
|
|
274
275
|
errors.push('Multiple MpxWebpackPlugin instances exist in webpack compiler, please check webpack plugins config!')
|
|
275
276
|
}
|
|
276
277
|
|
|
278
|
+
// 将entry export标记为used且不可mangle,避免require.async生成的js chunk在生产环境下报错
|
|
279
|
+
new FlagEntryExportAsUsedPlugin(true, 'entry').apply(compiler)
|
|
280
|
+
|
|
277
281
|
if (this.options.mode !== 'web') {
|
|
278
282
|
// 强制设置publicPath为'/'
|
|
279
283
|
if (compiler.options.output.publicPath && compiler.options.output.publicPath !== publicPath) {
|
|
@@ -958,6 +962,8 @@ class MpxWebpackPlugin {
|
|
|
958
962
|
if (mpx.mode === 'wx') {
|
|
959
963
|
const dep = new DynamicEntryDependency(request, 'export', '', queryObj.root, MPX_CURRENT_CHUNK, context, range)
|
|
960
964
|
parser.state.current.addPresentationalDependency(dep)
|
|
965
|
+
// 包含require.async的模块不能被concatenate,避免DynamicEntryDependency中无法获取模块chunk以计算相对路径
|
|
966
|
+
parser.state.module.buildInfo.moduleConcatenationBailout = 'require async'
|
|
961
967
|
} else {
|
|
962
968
|
const range = expr.range
|
|
963
969
|
const dep = new CommonJsAsyncDependency(request, range)
|
|
@@ -60,7 +60,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
60
60
|
const resourceName = path.join(parsed.dir, parsed.name)
|
|
61
61
|
|
|
62
62
|
if (!outputPath) {
|
|
63
|
-
if (ext === '.js' && resourceName.includes('node_modules')) {
|
|
63
|
+
if (ext === '.js' && resourceName.includes('node_modules') && mode !== 'web') {
|
|
64
64
|
let root = info.descriptionFileRoot
|
|
65
65
|
let name = 'nativeComponent'
|
|
66
66
|
if (info.descriptionFileData) {
|
|
@@ -78,7 +78,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
78
78
|
outputPath = getOutputPath(resourcePath, 'component')
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
if (ext === '.js') {
|
|
81
|
+
if (ext === '.js' && mode !== 'web') {
|
|
82
82
|
resource = `!!${nativeLoaderPath}!${resource}`
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -116,7 +116,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
116
116
|
outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
if (ext === '.js') {
|
|
119
|
+
if (ext === '.js' && mode !== 'web') {
|
|
120
120
|
resource = `!!${nativeLoaderPath}!${resource}`
|
|
121
121
|
}
|
|
122
122
|
const entry = getDynamicEntry(resource, 'page', outputPath, tarRoot, publicPath + tarRoot)
|
|
@@ -210,12 +210,11 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
210
210
|
},
|
|
211
211
|
{
|
|
212
212
|
// 样式类名绑定
|
|
213
|
-
test: /^wx:class$/,
|
|
214
|
-
web ({
|
|
215
|
-
const dir = this.test.exec(name)[1]
|
|
213
|
+
test: /^wx:(class)$/,
|
|
214
|
+
web ({ value }) {
|
|
216
215
|
const parsed = parseMustache(value)
|
|
217
216
|
return {
|
|
218
|
-
name: ':'
|
|
217
|
+
name: ':class',
|
|
219
218
|
value: parsed.result
|
|
220
219
|
}
|
|
221
220
|
}
|
package/lib/web/processScript.js
CHANGED
|
@@ -119,6 +119,7 @@ module.exports = function (script, {
|
|
|
119
119
|
content += ` import '@mpxjs/webpack-plugin/lib/runtime/base.styl'
|
|
120
120
|
import Vue from 'vue'
|
|
121
121
|
import VueRouter from 'vue-router'
|
|
122
|
+
import Mpx from '@mpxjs/core'
|
|
122
123
|
Vue.use(VueRouter)
|
|
123
124
|
global.getApp = function(){}
|
|
124
125
|
global.getCurrentPages = function(){
|
|
@@ -160,9 +161,8 @@ module.exports = function (script, {
|
|
|
160
161
|
i18n.mergeLocaleMessage(locale, newMessages[locale])
|
|
161
162
|
})
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}\n`
|
|
164
|
+
Mpx.i18n = i18n
|
|
165
|
+
\n`
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
// 注入wxs模块
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.34",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=14.14.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "358e525525f4e3d0d4e0cf73978c446c8e4909c6"
|
|
84
84
|
}
|