@mpxjs/webpack-plugin 2.7.50 → 2.7.53
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/dependencies/DynamicEntryDependency.js +18 -11
- package/lib/extractor.js +2 -1
- package/lib/index.js +5 -5
- package/lib/loader.js +6 -1
- package/lib/runtime/components/web/mpx-picker.vue +14 -8
- package/lib/template-compiler/compiler.js +36 -18
- package/lib/template-compiler/index.js +3 -1
- package/package.json +2 -2
|
@@ -73,13 +73,20 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
73
73
|
resource = addQuery(resource, { packageRoot }, true)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const key = resource
|
|
77
|
-
let addEntryPromise
|
|
76
|
+
const key = [resource, filename].join('|')
|
|
78
77
|
|
|
79
78
|
if (alreadyOutputted) {
|
|
80
|
-
addEntryPromise = mpx.addEntryPromiseMap.get(key)
|
|
79
|
+
const addEntryPromise = mpx.addEntryPromiseMap.get(key)
|
|
80
|
+
if (addEntryPromise) {
|
|
81
|
+
addEntryPromise.then(entryModule => {
|
|
82
|
+
// 构建entry依赖图,针对alreadyOutputted的entry也需要记录
|
|
83
|
+
originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
// alreadyOutputted时直接返回,避免存在模块循环引用时死循环
|
|
87
|
+
return callback(null, { resultPath })
|
|
81
88
|
} else {
|
|
82
|
-
addEntryPromise = new Promise((resolve, reject) => {
|
|
89
|
+
const addEntryPromise = new Promise((resolve, reject) => {
|
|
83
90
|
mpx.addEntry(resource, filename, (err, entryModule) => {
|
|
84
91
|
if (err) return reject(err)
|
|
85
92
|
if (entryType === 'export') {
|
|
@@ -88,15 +95,15 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
88
95
|
resolve(entryModule)
|
|
89
96
|
})
|
|
90
97
|
})
|
|
98
|
+
addEntryPromise
|
|
99
|
+
.then(entryModule => {
|
|
100
|
+
originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
101
|
+
callback(null, { resultPath })
|
|
102
|
+
})
|
|
103
|
+
.catch(err => callback(err))
|
|
104
|
+
|
|
91
105
|
mpx.addEntryPromiseMap.set(key, addEntryPromise)
|
|
92
106
|
}
|
|
93
|
-
|
|
94
|
-
addEntryPromise
|
|
95
|
-
.then(entryModule => {
|
|
96
|
-
if (entryModule) originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
97
|
-
callback(null, { resultPath })
|
|
98
|
-
})
|
|
99
|
-
.catch(err => callback(err))
|
|
100
107
|
}
|
|
101
108
|
], callback)
|
|
102
109
|
}
|
package/lib/extractor.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -147,7 +147,7 @@ class MpxWebpackPlugin {
|
|
|
147
147
|
options.auditResource = options.auditResource || false
|
|
148
148
|
options.decodeHTMLText = options.decodeHTMLText || false
|
|
149
149
|
options.i18n = options.i18n || null
|
|
150
|
-
options.
|
|
150
|
+
options.checkUsingComponentsRules = options.checkUsingComponentsRules || (options.checkUsingComponents ? { include: () => true } : { exclude: () => true })
|
|
151
151
|
options.reportSize = options.reportSize || null
|
|
152
152
|
options.pathHashMode = options.pathHashMode || 'absolute'
|
|
153
153
|
options.forceDisableBuiltInLoader = options.forceDisableBuiltInLoader || false
|
|
@@ -566,7 +566,7 @@ class MpxWebpackPlugin {
|
|
|
566
566
|
tabBarMap: {},
|
|
567
567
|
defs: preProcessDefs(this.options.defs),
|
|
568
568
|
i18n: this.options.i18n,
|
|
569
|
-
|
|
569
|
+
checkUsingComponentsRules: this.options.checkUsingComponentsRules,
|
|
570
570
|
forceDisableBuiltInLoader: this.options.forceDisableBuiltInLoader,
|
|
571
571
|
appTitle: 'Mpx homepage',
|
|
572
572
|
attributes: this.options.attributes,
|
|
@@ -1420,11 +1420,11 @@ try {
|
|
|
1420
1420
|
let mpxStyleLoaderIndex = -1
|
|
1421
1421
|
loaders.forEach((loader, index) => {
|
|
1422
1422
|
const currentLoader = toPosix(loader.loader)
|
|
1423
|
-
if (currentLoader.includes('css-loader')) {
|
|
1423
|
+
if (currentLoader.includes('css-loader') && cssLoaderIndex === -1) {
|
|
1424
1424
|
cssLoaderIndex = index
|
|
1425
|
-
} else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader')) {
|
|
1425
|
+
} else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader') && vueStyleLoaderIndex === -1) {
|
|
1426
1426
|
vueStyleLoaderIndex = index
|
|
1427
|
-
} else if (currentLoader.includes(styleCompilerPath)) {
|
|
1427
|
+
} else if (currentLoader.includes(styleCompilerPath) && mpxStyleLoaderIndex === -1) {
|
|
1428
1428
|
mpxStyleLoaderIndex = index
|
|
1429
1429
|
}
|
|
1430
1430
|
})
|
package/lib/loader.js
CHANGED
|
@@ -100,6 +100,7 @@ module.exports = function (content) {
|
|
|
100
100
|
const isNative = false
|
|
101
101
|
|
|
102
102
|
let usingComponents = [].concat(Object.keys(mpx.usingComponents))
|
|
103
|
+
let componentPlaceholder = []
|
|
103
104
|
|
|
104
105
|
let componentGenerics = {}
|
|
105
106
|
|
|
@@ -110,6 +111,9 @@ module.exports = function (content) {
|
|
|
110
111
|
fixUsingComponent(ret.usingComponents, mode)
|
|
111
112
|
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
112
113
|
}
|
|
114
|
+
if (ret.componentPlaceholder) {
|
|
115
|
+
componentPlaceholder = componentPlaceholder.concat(Object.values(ret.componentPlaceholder))
|
|
116
|
+
}
|
|
113
117
|
if (ret.componentGenerics) {
|
|
114
118
|
componentGenerics = Object.assign({}, ret.componentGenerics)
|
|
115
119
|
}
|
|
@@ -279,7 +283,8 @@ module.exports = function (content) {
|
|
|
279
283
|
hasComment,
|
|
280
284
|
isNative,
|
|
281
285
|
moduleId,
|
|
282
|
-
usingComponents
|
|
286
|
+
usingComponents,
|
|
287
|
+
componentPlaceholder
|
|
283
288
|
// 添加babel处理渲染函数中可能包含的...展开运算符
|
|
284
289
|
// 由于...运算符应用范围极小以及babel成本极高,先关闭此特性后续看情况打开
|
|
285
290
|
// needBabel: true
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
<div class="wheel" v-for="(data, index) in pickerData" :key="index">
|
|
19
19
|
<ul class="wheel-scroll">
|
|
20
20
|
<li
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
v-for="item in data" :key="item"
|
|
22
|
+
class="wheel-item">{{item}}
|
|
23
23
|
</li>
|
|
24
24
|
</ul>
|
|
25
25
|
</div>
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
import { type } from './util'
|
|
40
40
|
import { getCustomEvent } from './getInnerListeners'
|
|
41
41
|
|
|
42
|
-
const startYear =
|
|
42
|
+
const startYear = 1900
|
|
43
43
|
const modeOptions = {
|
|
44
44
|
time: [23, 59],
|
|
45
|
-
date: [
|
|
45
|
+
date: [200, 11, 30]
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
BScroll.use(Wheel)
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
let months = []
|
|
74
74
|
let days = []
|
|
75
75
|
|
|
76
|
-
for (let i = 0; i <=
|
|
76
|
+
for (let i = 0; i <= 200; i++) {
|
|
77
77
|
years.push(`${startYear + i}年`)
|
|
78
78
|
}
|
|
79
79
|
if (fields === 'year') {
|
|
@@ -127,11 +127,17 @@
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
-
start:
|
|
131
|
-
|
|
130
|
+
start: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: '1970-01-01'
|
|
133
|
+
},
|
|
134
|
+
end: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: '2100-01-01'
|
|
137
|
+
},
|
|
132
138
|
fields: {
|
|
133
139
|
type: String,
|
|
134
|
-
|
|
140
|
+
default: 'day'
|
|
135
141
|
}
|
|
136
142
|
},
|
|
137
143
|
data () {
|
|
@@ -835,10 +835,14 @@ function parse (template, options) {
|
|
|
835
835
|
Array.isArray(val.errorArray) && val.errorArray.forEach(item => error$1(item))
|
|
836
836
|
})
|
|
837
837
|
|
|
838
|
-
if (!tagNames.has('component')) {
|
|
838
|
+
if (!tagNames.has('component') && options.checkUsingComponents) {
|
|
839
|
+
const arr = []
|
|
839
840
|
options.usingComponents.forEach((item) => {
|
|
840
|
-
if (!tagNames.has(item) && !options.globalComponents.includes(item) && options.
|
|
841
|
+
if (!tagNames.has(item) && !options.globalComponents.includes(item) && !options.componentPlaceholder.includes(item)) {
|
|
842
|
+
arr.push(item)
|
|
843
|
+
}
|
|
841
844
|
})
|
|
845
|
+
arr.length && warn$1(`\n ${options.filePath} \n 组件 ${arr.join(' | ')} 注册了,但是未被对应的模板引用,建议删除!`)
|
|
842
846
|
}
|
|
843
847
|
|
|
844
848
|
return {
|
|
@@ -1957,7 +1961,7 @@ function postProcessTemplate (el) {
|
|
|
1957
1961
|
}
|
|
1958
1962
|
}
|
|
1959
1963
|
|
|
1960
|
-
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd')
|
|
1964
|
+
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,noMode')
|
|
1961
1965
|
|
|
1962
1966
|
const wrapRE = /^\((.*)\)$/
|
|
1963
1967
|
|
|
@@ -1989,32 +1993,46 @@ function processAtMode (el) {
|
|
|
1989
1993
|
return
|
|
1990
1994
|
}
|
|
1991
1995
|
|
|
1992
|
-
const conditionMap =
|
|
1993
|
-
|
|
1996
|
+
const conditionMap = new Map()
|
|
1994
1997
|
modeStr.split('|').forEach(item => {
|
|
1995
1998
|
const arr = item.split(':')
|
|
1996
|
-
const key = arr[0] ||
|
|
1997
|
-
conditionMap
|
|
1999
|
+
const key = arr[0] || 'noMode'
|
|
2000
|
+
conditionMap.set(key, arr.slice(1))
|
|
1998
2001
|
})
|
|
1999
2002
|
|
|
2000
|
-
const modeArr =
|
|
2003
|
+
const modeArr = [...conditionMap.keys()]
|
|
2001
2004
|
|
|
2002
2005
|
if (modeArr.every(i => isValidMode(i))) {
|
|
2003
2006
|
const attrValue = getAndRemoveAttr(el, attrName).val
|
|
2004
2007
|
const replacedAttrName = attrArr.join('@')
|
|
2005
|
-
|
|
2006
2008
|
const processedAttr = { name: replacedAttrName, value: attrValue }
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2009
|
+
|
|
2010
|
+
for (let [defineMode, defineEnvArr] of conditionMap.entries()) {
|
|
2011
|
+
if (defineMode === 'noMode' || defineMode === mode) {
|
|
2012
|
+
// 命中 env 规则(没有定义env 或者定义的envArr包含当前env)
|
|
2013
|
+
if (!defineEnvArr.length || defineEnvArr.includes(env)) {
|
|
2014
|
+
el._atModeStatus = ''
|
|
2015
|
+
if (!replacedAttrName) {
|
|
2016
|
+
// 若defineMode 为 noMode,则不论是element,还是attr,都需要经过规则转换
|
|
2017
|
+
if (defineMode !== 'noMode') {
|
|
2018
|
+
el._atModeStatus = 'match'
|
|
2019
|
+
}
|
|
2020
|
+
} else {
|
|
2021
|
+
// 如果命中了指定的mode,则先存在el上,等跑完转换后再挂回去
|
|
2022
|
+
el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
|
|
2023
|
+
}
|
|
2024
|
+
// 命中mode,命中env,完成匹配,直接退出
|
|
2025
|
+
break
|
|
2026
|
+
} else if (!replacedAttrName) {
|
|
2027
|
+
// 命中mode规则,没有命中当前env规则,设置为 'mismatch'
|
|
2028
|
+
el._atModeStatus = 'mismatch'
|
|
2029
|
+
}
|
|
2030
|
+
} else if (!replacedAttrName) {
|
|
2031
|
+
// 没有命中当前mode规则,设置为 'mismatch'
|
|
2032
|
+
el._atModeStatus = 'mismatch'
|
|
2010
2033
|
} else {
|
|
2011
|
-
//
|
|
2012
|
-
el.noTransAttrs ? el.noTransAttrs.push(processedAttr) : el.noTransAttrs = [processedAttr]
|
|
2034
|
+
// 如果没命中指定的mode,则该属性删除
|
|
2013
2035
|
}
|
|
2014
|
-
} else if (!replacedAttrName) {
|
|
2015
|
-
el._atModeStatus = 'mismatch'
|
|
2016
|
-
} else {
|
|
2017
|
-
// 如果没命中指定的mode,则该属性删除
|
|
2018
2036
|
}
|
|
2019
2037
|
}
|
|
2020
2038
|
})
|
|
@@ -21,6 +21,7 @@ module.exports = function (raw) {
|
|
|
21
21
|
const componentsMap = mpx.componentsMap[packageName]
|
|
22
22
|
const wxsContentMap = mpx.wxsContentMap
|
|
23
23
|
const usingComponents = queryObj.usingComponents || []
|
|
24
|
+
const componentPlaceholder = queryObj.componentPlaceholder || []
|
|
24
25
|
const hasComment = queryObj.hasComment
|
|
25
26
|
const isNative = queryObj.isNative
|
|
26
27
|
const hasScoped = queryObj.hasScoped
|
|
@@ -42,6 +43,7 @@ module.exports = function (raw) {
|
|
|
42
43
|
warn,
|
|
43
44
|
error,
|
|
44
45
|
usingComponents,
|
|
46
|
+
componentPlaceholder,
|
|
45
47
|
hasComment,
|
|
46
48
|
isNative,
|
|
47
49
|
isComponent: !!componentsMap[resourcePath],
|
|
@@ -56,7 +58,7 @@ module.exports = function (raw) {
|
|
|
56
58
|
// 这里需传递resourcePath和wxsContentMap保持一致
|
|
57
59
|
filePath: resourcePath,
|
|
58
60
|
i18n,
|
|
59
|
-
checkUsingComponents: mpx.
|
|
61
|
+
checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
|
|
60
62
|
globalComponents: Object.keys(mpx.usingComponents),
|
|
61
63
|
forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules),
|
|
62
64
|
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.53",
|
|
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": "33d25192ef4411be890f1af07a8b6d11557403e4"
|
|
84
84
|
}
|