@mpxjs/webpack-plugin 2.8.25 → 2.8.28-beta.0
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 +11 -16
- package/lib/index.js +23 -9
- package/lib/json-compiler/index.js +8 -1
- package/lib/platform/template/wx/component-config/component.js +1 -2
- package/lib/platform/template/wx/index.js +11 -13
- package/lib/template-compiler/compiler.js +72 -49
- package/lib/wxss/loader.js +3 -3
- package/package.json +3 -3
- package/lib/utils/fix-swan-relative.js +0 -6
|
@@ -28,23 +28,10 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
28
28
|
return toPosix([request, entryType, outputPath, packageRoot, relativePath, context, ...range].join('|'))
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
collectDynamicRequest (mpx) {
|
|
32
|
-
if (!this.packageRoot) return
|
|
33
|
-
const curValue = mpx.dynamicEntryInfo[this.packageRoot] = mpx.dynamicEntryInfo[this.packageRoot] || {
|
|
34
|
-
hasPage: false,
|
|
35
|
-
entries: []
|
|
36
|
-
}
|
|
37
|
-
if (this.entryType === 'page') {
|
|
38
|
-
curValue.hasPage = true
|
|
39
|
-
} else {
|
|
40
|
-
curValue.entries.push(this.request)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
31
|
addEntry (compilation, callback) {
|
|
45
32
|
const mpx = compilation.__mpx__
|
|
46
33
|
let { request, entryType, outputPath, relativePath, context, originEntryNode, publicPath, resolver } = this
|
|
47
|
-
|
|
34
|
+
|
|
48
35
|
async.waterfall([
|
|
49
36
|
(callback) => {
|
|
50
37
|
if (context && resolver) {
|
|
@@ -56,12 +43,13 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
56
43
|
}
|
|
57
44
|
},
|
|
58
45
|
(resource, callback) => {
|
|
46
|
+
const { resourcePath } = parseRequest(resource)
|
|
47
|
+
|
|
59
48
|
if (!outputPath) {
|
|
60
|
-
const { resourcePath } = parseRequest(resource)
|
|
61
49
|
outputPath = mpx.getOutputPath(resourcePath, entryType)
|
|
62
50
|
}
|
|
63
51
|
|
|
64
|
-
const { packageRoot, outputPath: filename, alreadyOutputted } = mpx.getPackageInfo({
|
|
52
|
+
const { packageName, packageRoot, outputPath: filename, alreadyOutputted } = mpx.getPackageInfo({
|
|
65
53
|
resource,
|
|
66
54
|
outputPath,
|
|
67
55
|
resourceType: entryType,
|
|
@@ -88,6 +76,13 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
88
76
|
|
|
89
77
|
const key = [resource, filename].join('|')
|
|
90
78
|
|
|
79
|
+
mpx.collectDynamicEntryInfo({
|
|
80
|
+
resource,
|
|
81
|
+
packageName,
|
|
82
|
+
filename,
|
|
83
|
+
entryType
|
|
84
|
+
})
|
|
85
|
+
|
|
91
86
|
if (alreadyOutputted) {
|
|
92
87
|
const addEntryPromise = mpx.addEntryPromiseMap.get(key)
|
|
93
88
|
if (addEntryPromise) {
|
package/lib/index.js
CHANGED
|
@@ -454,17 +454,17 @@ class MpxWebpackPlugin {
|
|
|
454
454
|
stage: -1000
|
|
455
455
|
}, (compilation, callback) => {
|
|
456
456
|
processSubpackagesEntriesMap(compilation, () => {
|
|
457
|
-
const
|
|
458
|
-
for (const
|
|
459
|
-
const entryMap = mpx.dynamicEntryInfo[
|
|
460
|
-
if (!entryMap.hasPage) {
|
|
457
|
+
const checkDynamicEntryInfo = () => {
|
|
458
|
+
for (const packageName in mpx.dynamicEntryInfo) {
|
|
459
|
+
const entryMap = mpx.dynamicEntryInfo[packageName]
|
|
460
|
+
if (packageName !== 'main' && !entryMap.hasPage) {
|
|
461
461
|
// 引用未注册分包的所有资源
|
|
462
|
-
const
|
|
463
|
-
compilation.errors.push(new Error(`资源${
|
|
462
|
+
const resources = entryMap.entries.map(info => info.resource).join(',')
|
|
463
|
+
compilation.errors.push(new Error(`资源${resources}通过分包异步声明为${packageName}分包, 但${packageName}分包未注册或不存在相关页面!`))
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
checkDynamicEntryInfo()
|
|
468
468
|
callback()
|
|
469
469
|
})
|
|
470
470
|
})
|
|
@@ -550,7 +550,7 @@ class MpxWebpackPlugin {
|
|
|
550
550
|
subpackagesEntriesMap: {},
|
|
551
551
|
replacePathMap: {},
|
|
552
552
|
exportModules: new Set(),
|
|
553
|
-
//
|
|
553
|
+
// 记录动态添加入口的分包信息
|
|
554
554
|
dynamicEntryInfo: {},
|
|
555
555
|
// 记录entryModule与entryNode的对应关系,用于体积分析
|
|
556
556
|
entryNodeModulesMap: new Map(),
|
|
@@ -593,13 +593,27 @@ class MpxWebpackPlugin {
|
|
|
593
593
|
removedChunks: [],
|
|
594
594
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
595
595
|
enableAliRequireAsync: this.options.enableAliRequireAsync,
|
|
596
|
+
collectDynamicEntryInfo: ({ resource, packageName, filename, entryType }) => {
|
|
597
|
+
const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
|
|
598
|
+
hasPage: false,
|
|
599
|
+
entries: []
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (entryType === 'page') curInfo.hasPage = true
|
|
603
|
+
|
|
604
|
+
curInfo.entries.push({
|
|
605
|
+
entryType,
|
|
606
|
+
resource,
|
|
607
|
+
filename
|
|
608
|
+
})
|
|
609
|
+
},
|
|
596
610
|
pathHash: (resourcePath) => {
|
|
597
611
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
598
612
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
599
613
|
}
|
|
600
614
|
return hash(resourcePath)
|
|
601
615
|
},
|
|
602
|
-
addEntry (request, name, callback) {
|
|
616
|
+
addEntry: (request, name, callback) => {
|
|
603
617
|
const dep = EntryPlugin.createDependency(request, { name })
|
|
604
618
|
compilation.addEntry(compiler.context, dep, { name }, callback)
|
|
605
619
|
return dep
|
|
@@ -98,7 +98,14 @@ module.exports = function (content) {
|
|
|
98
98
|
if (err) return callback(err)
|
|
99
99
|
if (!this._compilation) return callback()
|
|
100
100
|
const targetPath = path.relative(context, file)
|
|
101
|
-
this.
|
|
101
|
+
this._compilation.assets[targetPath] = {
|
|
102
|
+
size: function size () {
|
|
103
|
+
return stats.size
|
|
104
|
+
},
|
|
105
|
+
source: function source () {
|
|
106
|
+
return content
|
|
107
|
+
}
|
|
108
|
+
}
|
|
102
109
|
callback()
|
|
103
110
|
})
|
|
104
111
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const parseMustache = templateCompiler.parseMustache
|
|
1
|
+
const { parseMustache } = require('../../../../template-compiler/compiler')
|
|
3
2
|
const normalize = require('../../../../utils/normalize')
|
|
4
3
|
const TAG_NAME = 'component'
|
|
5
4
|
|
|
@@ -3,9 +3,7 @@ const JSON5 = require('json5')
|
|
|
3
3
|
const getComponentConfigs = require('./component-config')
|
|
4
4
|
const normalizeComponentRules = require('../normalize-component-rules')
|
|
5
5
|
const isValidIdentifierStr = require('../../../utils/is-valid-identifier-str')
|
|
6
|
-
const
|
|
7
|
-
const parseMustache = templateCompiler.parseMustache
|
|
8
|
-
const stringifyWithResolveComputed = templateCompiler.stringifyWithResolveComputed
|
|
6
|
+
const { parseMustacheWithContext, stringifyWithResolveComputed } = require('../../../template-compiler/compiler')
|
|
9
7
|
const normalize = require('../../../utils/normalize')
|
|
10
8
|
|
|
11
9
|
module.exports = function getSpec ({ warn, error }) {
|
|
@@ -17,10 +15,10 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
17
15
|
postProps: [
|
|
18
16
|
{
|
|
19
17
|
web ({ name, value }) {
|
|
20
|
-
const parsed =
|
|
18
|
+
const parsed = parseMustacheWithContext(value)
|
|
21
19
|
if (parsed.hasBinding) {
|
|
22
20
|
return {
|
|
23
|
-
name: name === 'animation' ? 'v-'
|
|
21
|
+
name: name === 'animation' ? 'v-animation' : ':' + name,
|
|
24
22
|
value: parsed.result
|
|
25
23
|
}
|
|
26
24
|
}
|
|
@@ -34,7 +32,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
34
32
|
test: 'wx:for',
|
|
35
33
|
swan (obj, data) {
|
|
36
34
|
const attrsMap = data.el.attrsMap
|
|
37
|
-
const parsed =
|
|
35
|
+
const parsed = parseMustacheWithContext(obj.value)
|
|
38
36
|
let listName = parsed.result
|
|
39
37
|
const el = data.el
|
|
40
38
|
|
|
@@ -48,7 +46,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
if (keyName) {
|
|
51
|
-
const parsed =
|
|
49
|
+
const parsed = parseMustacheWithContext(keyName)
|
|
52
50
|
if (parsed.hasBinding) {
|
|
53
51
|
// keyStr = ` trackBy ${parsed.result.slice(1, -1)}`
|
|
54
52
|
} else if (keyName === '*this') {
|
|
@@ -78,7 +76,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
78
76
|
}
|
|
79
77
|
},
|
|
80
78
|
web ({ value }, { el }) {
|
|
81
|
-
const parsed =
|
|
79
|
+
const parsed = parseMustacheWithContext(value)
|
|
82
80
|
const attrsMap = el.attrsMap
|
|
83
81
|
const itemName = attrsMap['wx:for-item'] || 'item'
|
|
84
82
|
const indexName = attrsMap['wx:for-index'] || 'index'
|
|
@@ -191,15 +189,15 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
191
189
|
const styleBinding = []
|
|
192
190
|
el.isStyleParsed = true
|
|
193
191
|
el.attrsList.forEach((item) => {
|
|
194
|
-
const parsed =
|
|
192
|
+
const parsed = parseMustacheWithContext(item.value)
|
|
195
193
|
if (item.name === 'style') {
|
|
196
194
|
if (parsed.hasBinding || parsed.result.indexOf('rpx') > -1) {
|
|
197
|
-
styleBinding.push(
|
|
195
|
+
styleBinding.push(parseMustacheWithContext(item.value).result)
|
|
198
196
|
} else {
|
|
199
197
|
styleBinding.push(JSON.stringify(item.value))
|
|
200
198
|
}
|
|
201
199
|
} else if (item.name === 'wx:style') {
|
|
202
|
-
styleBinding.push(
|
|
200
|
+
styleBinding.push(parseMustacheWithContext(item.value).result)
|
|
203
201
|
}
|
|
204
202
|
})
|
|
205
203
|
return {
|
|
@@ -212,7 +210,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
212
210
|
// 样式类名绑定
|
|
213
211
|
test: /^wx:(class)$/,
|
|
214
212
|
web ({ value }) {
|
|
215
|
-
const parsed =
|
|
213
|
+
const parsed = parseMustacheWithContext(value)
|
|
216
214
|
return {
|
|
217
215
|
name: ':class',
|
|
218
216
|
value: parsed.result
|
|
@@ -266,7 +264,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
266
264
|
},
|
|
267
265
|
web ({ name, value }) {
|
|
268
266
|
let dir = this.test.exec(name)[1]
|
|
269
|
-
const parsed =
|
|
267
|
+
const parsed = parseMustacheWithContext(value)
|
|
270
268
|
if (dir === 'elif') {
|
|
271
269
|
dir = 'else-if'
|
|
272
270
|
}
|
|
@@ -967,7 +967,7 @@ function processComponentIs (el, options) {
|
|
|
967
967
|
|
|
968
968
|
const is = getAndRemoveAttr(el, 'is').val
|
|
969
969
|
if (is) {
|
|
970
|
-
el.is =
|
|
970
|
+
el.is = parseMustacheWithContext(is).result
|
|
971
971
|
} else {
|
|
972
972
|
warn$1('<component> tag should have attrs[is].')
|
|
973
973
|
}
|
|
@@ -979,7 +979,7 @@ function parseFuncStr2 (str) {
|
|
|
979
979
|
const funcRE = /^([^()]+)(\((.*)\))?/
|
|
980
980
|
const match = funcRE.exec(str)
|
|
981
981
|
if (match) {
|
|
982
|
-
const funcName =
|
|
982
|
+
const funcName = parseMustacheWithContext(match[1]).result
|
|
983
983
|
const hasArgs = !!match[2]
|
|
984
984
|
let args = match[3] ? `,${match[3]}` : ''
|
|
985
985
|
const ret = /(,|^)\s*(\$event)\s*(,|$)/.exec(args)
|
|
@@ -1163,19 +1163,9 @@ function wrapMustache (val) {
|
|
|
1163
1163
|
return val && !tagRE.test(val) ? `{{${val}}}` : val
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
|
-
function
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const ret = []
|
|
1170
|
-
let lastLastIndex = 0
|
|
1171
|
-
let match
|
|
1172
|
-
while (match = tagREG.exec(raw)) {
|
|
1173
|
-
const pre = raw.substring(lastLastIndex, match.index)
|
|
1174
|
-
if (pre) {
|
|
1175
|
-
ret.push(stringify(pre))
|
|
1176
|
-
}
|
|
1177
|
-
let exp = match[1]
|
|
1178
|
-
|
|
1166
|
+
function parseMustacheWithContext (raw = '') {
|
|
1167
|
+
return parseMustache(raw, (exp) => {
|
|
1168
|
+
if (defs) {
|
|
1179
1169
|
// eval处理的话,和别的判断条件,比如运行时的判断混用情况下得不到一个结果,还是正则替换
|
|
1180
1170
|
const defKeys = Object.keys(defs)
|
|
1181
1171
|
defKeys.forEach((defKey) => {
|
|
@@ -1183,42 +1173,70 @@ function parseMustache (raw = '') {
|
|
|
1183
1173
|
const defREG = new RegExp(`\\b${defKey}\\b`, 'g')
|
|
1184
1174
|
if (defRE.test(exp)) {
|
|
1185
1175
|
exp = exp.replace(defREG, stringify(defs[defKey]))
|
|
1186
|
-
replaced = true
|
|
1187
1176
|
}
|
|
1188
1177
|
})
|
|
1178
|
+
}
|
|
1189
1179
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
}
|
|
1202
|
-
hasI18n = true
|
|
1203
|
-
replaced = true
|
|
1204
|
-
break
|
|
1180
|
+
if (i18n) {
|
|
1181
|
+
for (const i18nFuncName of i18nFuncNames) {
|
|
1182
|
+
const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
|
|
1183
|
+
const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
|
|
1184
|
+
if (funcNameRE.test(exp)) {
|
|
1185
|
+
if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
|
|
1186
|
+
const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
|
|
1187
|
+
i18nInjectableComputed.push(`${i18nInjectComputedKey} () {\nreturn ${exp.trim()}}`)
|
|
1188
|
+
exp = i18nInjectComputedKey
|
|
1189
|
+
} else {
|
|
1190
|
+
exp = exp.replace(funcNameREG, `${i18nModuleName}.$1(null, _l, _fl, `)
|
|
1205
1191
|
}
|
|
1192
|
+
hasI18n = true
|
|
1193
|
+
break
|
|
1206
1194
|
}
|
|
1207
1195
|
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
return exp
|
|
1199
|
+
})
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
function parseMustache (raw = '', expHandler = exp => exp, strHandler = str => str) {
|
|
1203
|
+
let replaced = false
|
|
1204
|
+
if (tagRE.test(raw)) {
|
|
1205
|
+
const ret = []
|
|
1206
|
+
let lastLastIndex = 0
|
|
1207
|
+
let match
|
|
1208
|
+
while (match = tagREG.exec(raw)) {
|
|
1209
|
+
const pre = raw.substring(lastLastIndex, match.index)
|
|
1210
|
+
if (pre) {
|
|
1211
|
+
const pre2 = strHandler(pre)
|
|
1212
|
+
if (pre2 !== pre) replaced = true
|
|
1213
|
+
if (pre2) ret.push(stringify(pre2))
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
const exp = match[1].trim()
|
|
1217
|
+
if (exp) {
|
|
1218
|
+
const exp2 = expHandler(exp)
|
|
1219
|
+
if (exp2 !== exp) replaced = true
|
|
1220
|
+
if (exp2) ret.push(`(${exp2})`)
|
|
1221
|
+
}
|
|
1208
1222
|
|
|
1209
|
-
ret.push(`(${exp.trim()})`)
|
|
1210
1223
|
lastLastIndex = tagREG.lastIndex
|
|
1211
1224
|
}
|
|
1225
|
+
|
|
1212
1226
|
const post = raw.substring(lastLastIndex)
|
|
1213
1227
|
if (post) {
|
|
1214
|
-
|
|
1228
|
+
const post2 = strHandler(post)
|
|
1229
|
+
if (post2 !== post) replaced = true
|
|
1230
|
+
if (post2) ret.push(stringify(post2))
|
|
1215
1231
|
}
|
|
1232
|
+
|
|
1216
1233
|
let result
|
|
1217
1234
|
if (ret.length === 1) {
|
|
1218
1235
|
result = ret[0]
|
|
1219
1236
|
} else {
|
|
1220
1237
|
result = `(${ret.join('+')})`
|
|
1221
1238
|
}
|
|
1239
|
+
|
|
1222
1240
|
return {
|
|
1223
1241
|
result,
|
|
1224
1242
|
hasBinding: true,
|
|
@@ -1226,10 +1244,14 @@ function parseMustache (raw = '') {
|
|
|
1226
1244
|
replaced
|
|
1227
1245
|
}
|
|
1228
1246
|
}
|
|
1247
|
+
|
|
1248
|
+
const raw2 = strHandler(raw)
|
|
1249
|
+
if (raw2 !== raw) replaced = true
|
|
1250
|
+
|
|
1229
1251
|
return {
|
|
1230
|
-
result: stringify(
|
|
1252
|
+
result: stringify(raw2),
|
|
1231
1253
|
hasBinding: false,
|
|
1232
|
-
val:
|
|
1254
|
+
val: raw2,
|
|
1233
1255
|
replaced
|
|
1234
1256
|
}
|
|
1235
1257
|
}
|
|
@@ -1247,14 +1269,14 @@ function processIf (el) {
|
|
|
1247
1269
|
let val = getAndRemoveAttr(el, config[mode].directive.if).val
|
|
1248
1270
|
if (val) {
|
|
1249
1271
|
if (mode === 'swan') val = wrapMustache(val)
|
|
1250
|
-
const parsed =
|
|
1272
|
+
const parsed = parseMustacheWithContext(val)
|
|
1251
1273
|
el.if = {
|
|
1252
1274
|
raw: parsed.val,
|
|
1253
1275
|
exp: parsed.result
|
|
1254
1276
|
}
|
|
1255
1277
|
} else if (val = getAndRemoveAttr(el, config[mode].directive.elseif).val) {
|
|
1256
1278
|
if (mode === 'swan') val = wrapMustache(val)
|
|
1257
|
-
const parsed =
|
|
1279
|
+
const parsed = parseMustacheWithContext(val)
|
|
1258
1280
|
el.elseif = {
|
|
1259
1281
|
raw: parsed.val,
|
|
1260
1282
|
exp: parsed.result
|
|
@@ -1296,7 +1318,7 @@ function processFor (el) {
|
|
|
1296
1318
|
}
|
|
1297
1319
|
} else {
|
|
1298
1320
|
if (mode === 'swan') val = wrapMustache(val)
|
|
1299
|
-
const parsed =
|
|
1321
|
+
const parsed = parseMustacheWithContext(val)
|
|
1300
1322
|
el.for = {
|
|
1301
1323
|
raw: parsed.val,
|
|
1302
1324
|
exp: parsed.result
|
|
@@ -1408,14 +1430,14 @@ function processAttrs (el, options) {
|
|
|
1408
1430
|
const isTemplateData = el.tag === 'template' && attr.name === 'data'
|
|
1409
1431
|
const needWrap = isTemplateData && mode !== 'swan'
|
|
1410
1432
|
const value = needWrap ? `{${attr.value}}` : attr.value
|
|
1411
|
-
const parsed =
|
|
1433
|
+
const parsed = parseMustacheWithContext(value)
|
|
1412
1434
|
if (parsed.hasBinding) {
|
|
1413
1435
|
// 该属性判断用于提供给运行时对于计算属性作为props传递时提出警告
|
|
1414
1436
|
const isProps = isComponentNode(el, options) && !(attr.name === 'class' || attr.name === 'style')
|
|
1415
1437
|
addExp(el, parsed.result, isProps)
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1438
|
+
if (parsed.replaced) {
|
|
1439
|
+
modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
|
|
1440
|
+
}
|
|
1419
1441
|
}
|
|
1420
1442
|
})
|
|
1421
1443
|
}
|
|
@@ -1547,7 +1569,7 @@ function processText (el) {
|
|
|
1547
1569
|
if (el.type !== 3 || el.isComment) {
|
|
1548
1570
|
return
|
|
1549
1571
|
}
|
|
1550
|
-
const parsed =
|
|
1572
|
+
const parsed = parseMustacheWithContext(el.text)
|
|
1551
1573
|
if (parsed.hasBinding) {
|
|
1552
1574
|
addExp(el, parsed.result)
|
|
1553
1575
|
}
|
|
@@ -1592,8 +1614,8 @@ function processClass (el, meta) {
|
|
|
1592
1614
|
let staticClass = getAndRemoveAttr(el, type).val || ''
|
|
1593
1615
|
staticClass = staticClass.replace(/\s+/g, ' ')
|
|
1594
1616
|
if (dynamicClass) {
|
|
1595
|
-
const staticClassExp =
|
|
1596
|
-
const dynamicClassExp = transDynamicClassExpr(
|
|
1617
|
+
const staticClassExp = parseMustacheWithContext(staticClass).result
|
|
1618
|
+
const dynamicClassExp = transDynamicClassExpr(parseMustacheWithContext(dynamicClass).result, {
|
|
1597
1619
|
error: error$1
|
|
1598
1620
|
})
|
|
1599
1621
|
addAttrs(el, [{
|
|
@@ -1628,8 +1650,8 @@ function processStyle (el, meta) {
|
|
|
1628
1650
|
let staticStyle = getAndRemoveAttr(el, type).val || ''
|
|
1629
1651
|
staticStyle = staticStyle.replace(/\s+/g, ' ')
|
|
1630
1652
|
if (dynamicStyle) {
|
|
1631
|
-
const staticStyleExp =
|
|
1632
|
-
const dynamicStyleExp =
|
|
1653
|
+
const staticStyleExp = parseMustacheWithContext(staticStyle).result
|
|
1654
|
+
const dynamicStyleExp = parseMustacheWithContext(dynamicStyle).result
|
|
1633
1655
|
addAttrs(el, [{
|
|
1634
1656
|
name: targetType,
|
|
1635
1657
|
value: `{{${stringifyModuleName}.stringifyStyle(${staticStyleExp}, ${dynamicStyleExp})}}`
|
|
@@ -1870,7 +1892,7 @@ function processShow (el, options, root) {
|
|
|
1870
1892
|
if (options.hasVirtualHost) {
|
|
1871
1893
|
if (options.isComponent && el.parent === root && isRealNode(el)) {
|
|
1872
1894
|
if (show !== undefined) {
|
|
1873
|
-
show = `{{${
|
|
1895
|
+
show = `{{${parseMustacheWithContext(show).result}&&mpxShow}}`
|
|
1874
1896
|
} else {
|
|
1875
1897
|
show = '{{mpxShow}}'
|
|
1876
1898
|
}
|
|
@@ -1892,7 +1914,7 @@ function processShow (el, options, root) {
|
|
|
1892
1914
|
|
|
1893
1915
|
function processShowStyle () {
|
|
1894
1916
|
if (show !== undefined) {
|
|
1895
|
-
const showExp =
|
|
1917
|
+
const showExp = parseMustacheWithContext(show).result
|
|
1896
1918
|
let oldStyle = getAndRemoveAttr(el, 'style').val
|
|
1897
1919
|
oldStyle = oldStyle ? oldStyle + ';' : ''
|
|
1898
1920
|
addAttrs(el, [{
|
|
@@ -2376,6 +2398,7 @@ module.exports = {
|
|
|
2376
2398
|
makeAttrsMap,
|
|
2377
2399
|
stringifyAttr,
|
|
2378
2400
|
parseMustache,
|
|
2401
|
+
parseMustacheWithContext,
|
|
2379
2402
|
stringifyWithResolveComputed,
|
|
2380
2403
|
addAttrs
|
|
2381
2404
|
}
|
package/lib/wxss/loader.js
CHANGED
|
@@ -223,18 +223,18 @@ module.exports = async function loader (content, map, meta) {
|
|
|
223
223
|
imports.unshift({
|
|
224
224
|
type: 'api_import',
|
|
225
225
|
importName: '___CSS_LOADER_API_IMPORT___',
|
|
226
|
-
url: stringifyRequest(this,
|
|
226
|
+
url: stringifyRequest(this, require.resolve('./runtime/api'))
|
|
227
227
|
})
|
|
228
228
|
|
|
229
229
|
if (options.sourceMap) {
|
|
230
230
|
imports.unshift({
|
|
231
231
|
importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___',
|
|
232
|
-
url: stringifyRequest(this,
|
|
232
|
+
url: stringifyRequest(this, require.resolve('./runtime/sourceMaps'))
|
|
233
233
|
})
|
|
234
234
|
} else {
|
|
235
235
|
imports.unshift({
|
|
236
236
|
importName: '___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___',
|
|
237
|
-
url: stringifyRequest(this,
|
|
237
|
+
url: stringifyRequest(this, require.resolve('./runtime/noSourceMaps'))
|
|
238
238
|
})
|
|
239
239
|
}
|
|
240
240
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.28-beta.0",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
7
7
|
],
|
|
8
8
|
"author": "donghongping",
|
|
9
|
-
"license": "Apache",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"directories": {
|
|
12
12
|
"lib": "lib"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "632d66299998f93fe86cbabbd721ffa62f66d423"
|
|
86
86
|
}
|