@mpxjs/webpack-plugin 2.8.37 → 2.8.39
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
|
@@ -594,7 +594,7 @@ class MpxWebpackPlugin {
|
|
|
594
594
|
useRelativePath: this.options.useRelativePath,
|
|
595
595
|
removedChunks: [],
|
|
596
596
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
597
|
-
|
|
597
|
+
enableRequireAsync: this.options.mode === 'wx' || (this.options.mode === 'ali' && this.options.enableAliRequireAsync),
|
|
598
598
|
pathHash: (resourcePath) => {
|
|
599
599
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
600
600
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
@@ -1003,8 +1003,8 @@ class MpxWebpackPlugin {
|
|
|
1003
1003
|
if (queryObj.root) {
|
|
1004
1004
|
// 删除root query
|
|
1005
1005
|
request = addQuery(request, {}, false, ['root'])
|
|
1006
|
-
// 目前仅wx支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
|
|
1007
|
-
if (mpx.
|
|
1006
|
+
// 目前仅wx和ali支持require.async,ali需要开启enableAliRequireAsync,其余平台使用CommonJsAsyncDependency进行模拟抹平
|
|
1007
|
+
if (mpx.enableRequireAsync) {
|
|
1008
1008
|
const dep = new DynamicEntryDependency(request, 'export', '', queryObj.root, '', context, range, {
|
|
1009
1009
|
isRequireAsync: true,
|
|
1010
1010
|
retryRequireAsync: !!this.options.retryRequireAsync
|
|
@@ -16,7 +16,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
16
16
|
const pathHash = mpx.pathHash
|
|
17
17
|
const getOutputPath = mpx.getOutputPath
|
|
18
18
|
const mode = mpx.mode
|
|
19
|
-
const
|
|
19
|
+
const enableRequireAsync = mpx.enableRequireAsync
|
|
20
20
|
|
|
21
21
|
const isUrlRequest = r => isUrlRequestRaw(r, root, externals)
|
|
22
22
|
const urlToRequest = r => loaderUtils.urlToRequest(r)
|
|
@@ -54,7 +54,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
54
54
|
// 删除root query
|
|
55
55
|
resource = addQuery(resource, {}, false, ['root'])
|
|
56
56
|
// 目前只有微信支持分包异步化
|
|
57
|
-
if (
|
|
57
|
+
if (enableRequireAsync) tarRoot = queryObj.root
|
|
58
58
|
}
|
|
59
59
|
const parsed = path.parse(resourcePath)
|
|
60
60
|
const ext = parsed.ext
|
|
@@ -143,15 +143,17 @@ module.exports = function (content) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
// 校验异步组件占位符 componentPlaceholder 不为空
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
if (mpx.enableRequireAsync) {
|
|
147
|
+
const { usingComponents, componentPlaceholder = {} } = json
|
|
148
|
+
if (usingComponents) {
|
|
149
|
+
for (const compName in usingComponents) {
|
|
150
|
+
const compPath = usingComponents[compName]
|
|
151
|
+
if (!/\?root=/g.test(compPath)) continue
|
|
152
|
+
const compPlaceholder = componentPlaceholder[compName]
|
|
153
|
+
if (!compPlaceholder) {
|
|
154
|
+
const errMsg = `componentPlaceholder of "${compName}" doesn't exist! \n\r`
|
|
155
|
+
emitError(errMsg)
|
|
156
|
+
}
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
const normalize = require('./normalize')
|
|
2
|
-
const selectorPath = normalize.lib('selector.js')
|
|
3
|
-
const scriptSetupPath = normalize.lib('script-setup-compiler/index.js')
|
|
4
|
-
const mpxLoaderPath = normalize.lib('loader.js')
|
|
5
|
-
const { has } = require('./set')
|
|
6
|
-
|
|
7
|
-
const tsLoaderWatchRunFilterLoaders = new Set([
|
|
8
|
-
selectorPath,
|
|
9
|
-
scriptSetupPath,
|
|
10
|
-
mpxLoaderPath,
|
|
11
|
-
'node_modules/vue-loader/lib/index.js'
|
|
12
|
-
])
|
|
13
|
-
|
|
14
1
|
module.exports = (loaders, loaderIndex) => {
|
|
15
2
|
for (let len = loaders.length; len > 0; --len) {
|
|
16
3
|
const currentLoader = loaders[len - 1]
|
|
17
|
-
if (
|
|
4
|
+
if (currentLoader.path.endsWith('ts-loader/dist/stringify-loader.js')) {
|
|
18
5
|
break
|
|
19
6
|
}
|
|
20
7
|
loaderIndex--
|
package/lib/wxss/runtime/api.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
3
|
Author Tobias Koppers @sokra
|
|
4
4
|
*/
|
|
5
|
+
/* eslint no-var: off */
|
|
5
6
|
module.exports = function (cssWithMappingToString) {
|
|
6
|
-
|
|
7
|
+
var list = []
|
|
7
8
|
|
|
8
9
|
// return the list of modules as css string
|
|
9
10
|
list.toString = function toString () {
|
|
@@ -13,15 +14,15 @@ module.exports = function (cssWithMappingToString) {
|
|
|
13
14
|
var needLayer = typeof item[5] !== 'undefined'
|
|
14
15
|
|
|
15
16
|
if (item[4]) {
|
|
16
|
-
content +=
|
|
17
|
+
content += '@supports (' + item[4] + ') {'
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
if (item[2]) {
|
|
20
|
-
content +=
|
|
21
|
+
content += '@media ' + item[2] + '{'
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
if (needLayer) {
|
|
24
|
-
content +=
|
|
25
|
+
content += '@layer' + (item[5].length > 0 ? item[5] : '') + '{'
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
content += cssWithMappingToString(item)
|
|
@@ -51,7 +52,7 @@ module.exports = function (cssWithMappingToString) {
|
|
|
51
52
|
var alreadyImportedModules = {}
|
|
52
53
|
|
|
53
54
|
if (dedupe) {
|
|
54
|
-
for (
|
|
55
|
+
for (var k = 0; k < this.length; k++) {
|
|
55
56
|
var id = this[k][0]
|
|
56
57
|
|
|
57
58
|
if (id != null) {
|
|
@@ -60,8 +61,8 @@ module.exports = function (cssWithMappingToString) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
for (var
|
|
64
|
-
var item = [].concat(modules[
|
|
64
|
+
for (var k1 = 0; k1 < modules.length; k1++) {
|
|
65
|
+
var item = [].concat(modules[k1])
|
|
65
66
|
|
|
66
67
|
if (dedupe && alreadyImportedModules[item[0]]) {
|
|
67
68
|
continue
|
|
@@ -71,9 +72,7 @@ module.exports = function (cssWithMappingToString) {
|
|
|
71
72
|
if (typeof item[5] === 'undefined') {
|
|
72
73
|
item[5] = layer
|
|
73
74
|
} else {
|
|
74
|
-
item[1] =
|
|
75
|
-
item[1]
|
|
76
|
-
}}`
|
|
75
|
+
item[1] = '@layer' + (item[5].length > 0 ? item[5] : '') + '{' + item[1] + '}'
|
|
77
76
|
item[5] = layer
|
|
78
77
|
}
|
|
79
78
|
}
|
|
@@ -82,16 +81,16 @@ module.exports = function (cssWithMappingToString) {
|
|
|
82
81
|
if (!item[2]) {
|
|
83
82
|
item[2] = media
|
|
84
83
|
} else {
|
|
85
|
-
item[1] =
|
|
84
|
+
item[1] = '@media' + item[2] + item[1]
|
|
86
85
|
item[2] = media
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
if (supports) {
|
|
91
90
|
if (!item[4]) {
|
|
92
|
-
item[4] =
|
|
91
|
+
item[4] = String(supports)
|
|
93
92
|
} else {
|
|
94
|
-
item[1] =
|
|
93
|
+
item[1] = '@supports (' + item[4] + ')' + '{' + item[1] + '}'
|
|
95
94
|
item[4] = supports
|
|
96
95
|
}
|
|
97
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.39",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "c11c93eeb5315c5ff54df7ace05709a21bdaea53"
|
|
86
86
|
}
|