@mpxjs/webpack-plugin 2.8.39 → 2.8.40-test
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/CommonJsExtractDependency.js +51 -0
- package/lib/dependencies/ResolveDependency.js +11 -9
- package/lib/extractor.js +1 -0
- package/lib/helpers.js +9 -1
- package/lib/index.js +173 -72
- package/lib/json-compiler/helper.js +25 -9
- package/lib/json-compiler/index.js +77 -28
- package/lib/loader.js +3 -10
- package/lib/native-loader.js +21 -14
- package/lib/platform/json/wx/index.js +65 -2
- package/lib/platform/run-rules.js +2 -1
- package/lib/platform/template/normalize-component-rules.js +2 -0
- package/lib/platform/template/wx/component-config/README.md +1 -1
- package/lib/platform/template/wx/component-config/fix-html-tag.js +17 -0
- package/lib/platform/template/wx/component-config/hypen-tag-name.js +2 -6
- package/lib/platform/template/wx/component-config/index.js +4 -2
- package/lib/platform/template/wx/component-config/view.js +0 -11
- package/lib/platform/template/wx/index.js +65 -18
- package/lib/runtime/base.styl +0 -5
- package/lib/runtime/components/web/filterTag.js +9 -30
- package/lib/runtime/components/web/getInnerListeners.js +2 -14
- package/lib/runtime/components/web/mpx-keep-alive.vue +10 -17
- package/lib/runtime/components/web/mpx-movable-view.vue +105 -23
- package/lib/runtime/components/web/mpx-picker-view.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +69 -23
- package/lib/runtime/components/web/mpx-swiper.vue +152 -62
- package/lib/runtime/components/web/mpx-video.vue +123 -89
- package/lib/runtime/components/web/mpx-web-view.vue +120 -81
- package/lib/runtime/components/web/promisify.js +19 -0
- package/lib/runtime/components/wx/default-page.mpx +27 -0
- package/lib/runtime/optionProcessor.js +12 -18
- package/lib/style-compiler/index.js +5 -1
- package/lib/template-compiler/bind-this.js +280 -49
- package/lib/template-compiler/compiler.js +54 -58
- package/lib/template-compiler/index.js +35 -23
- package/lib/utils/dom-tag-config.js +115 -0
- package/lib/utils/make-map.js +12 -0
- package/lib/utils/string.js +7 -1
- package/lib/utils/ts-loader-watch-run-loader-filter.js +4 -5
- package/lib/web/processJSON.js +35 -0
- package/lib/web/processScript.js +7 -4
- package/lib/web/processTemplate.js +7 -34
- package/package.json +4 -4
- package/lib/partial-compile/index.js +0 -35
- package/lib/template-compiler/preprocessor.js +0 -29
- package/lib/wxss/compile-exports.js +0 -52
- package/lib/wxss/createResolver.js +0 -36
- package/lib/wxss/css-base.js +0 -79
- package/lib/wxss/getLocalIdent.js +0 -25
- package/lib/wxss/localsLoader.js +0 -44
- package/lib/wxss/processCss.js +0 -274
|
@@ -38,6 +38,7 @@ module.exports = function (content) {
|
|
|
38
38
|
const globalSrcMode = mpx.srcMode
|
|
39
39
|
const localSrcMode = queryObj.mode
|
|
40
40
|
const srcMode = localSrcMode || globalSrcMode
|
|
41
|
+
const projectRoot = mpx.projectRoot
|
|
41
42
|
|
|
42
43
|
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
43
44
|
const publicPath = this._compilation.outputOptions.publicPath || ''
|
|
@@ -55,6 +56,25 @@ module.exports = function (content) {
|
|
|
55
56
|
)
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
const fillInComponentPlaceholder = (name, placeholder, placeholderEntry) => {
|
|
60
|
+
const componentPlaceholder = json.componentPlaceholder || {}
|
|
61
|
+
if (componentPlaceholder[name]) return
|
|
62
|
+
componentPlaceholder[name] = placeholder
|
|
63
|
+
json.componentPlaceholder = componentPlaceholder
|
|
64
|
+
if (placeholderEntry && !json.usingComponents[placeholder]) json.usingComponents[placeholder] = placeholderEntry
|
|
65
|
+
}
|
|
66
|
+
const normalizePlaceholder = (placeholder) => {
|
|
67
|
+
if (typeof placeholder === 'string') {
|
|
68
|
+
placeholder = {
|
|
69
|
+
name: placeholder
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!placeholder.name) {
|
|
73
|
+
emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
|
|
74
|
+
}
|
|
75
|
+
return placeholder
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
const {
|
|
59
79
|
isUrlRequest,
|
|
60
80
|
urlToRequest,
|
|
@@ -134,6 +154,9 @@ module.exports = function (content) {
|
|
|
134
154
|
if (!json.usingComponents) {
|
|
135
155
|
json.usingComponents = {}
|
|
136
156
|
}
|
|
157
|
+
if (!json.component && mode === 'swan') {
|
|
158
|
+
json.component = true
|
|
159
|
+
}
|
|
137
160
|
}
|
|
138
161
|
} else if (componentsMap[resourcePath]) {
|
|
139
162
|
// component
|
|
@@ -142,22 +165,6 @@ module.exports = function (content) {
|
|
|
142
165
|
}
|
|
143
166
|
}
|
|
144
167
|
|
|
145
|
-
// 校验异步组件占位符 componentPlaceholder 不为空
|
|
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
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
168
|
// 快应用补全json配置,必填项
|
|
162
169
|
if (mode === 'qa' && isApp) {
|
|
163
170
|
const defaultConf = {
|
|
@@ -177,14 +184,14 @@ module.exports = function (content) {
|
|
|
177
184
|
type: 'json',
|
|
178
185
|
waterfall: true,
|
|
179
186
|
warn: emitWarning,
|
|
180
|
-
error: emitError
|
|
187
|
+
error: emitError,
|
|
188
|
+
data: {
|
|
189
|
+
// polyfill global usingComponents & record globalComponents
|
|
190
|
+
globalComponents: mpx.usingComponents
|
|
191
|
+
}
|
|
181
192
|
}
|
|
182
193
|
if (!isApp) {
|
|
183
194
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
184
|
-
// polyfill global usingComponents
|
|
185
|
-
rulesRunnerOptions.data = {
|
|
186
|
-
globalComponents: mpx.usingComponents
|
|
187
|
-
}
|
|
188
195
|
}
|
|
189
196
|
|
|
190
197
|
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
@@ -193,22 +200,47 @@ module.exports = function (content) {
|
|
|
193
200
|
rulesRunner(json)
|
|
194
201
|
}
|
|
195
202
|
|
|
196
|
-
if (isApp
|
|
203
|
+
if (isApp) {
|
|
204
|
+
Object.assign(mpx.usingComponents, json.usingComponents)
|
|
197
205
|
// 在 rulesRunner 运行后保存全局注册组件
|
|
198
|
-
|
|
206
|
+
// todo 其余地方在使用mpx.usingComponents时存在缓存问题,要规避该问题需要在所有使用mpx.usingComponents的loader中添加app resourcePath作为fileDependency,但对于缓存有效率影响巨大
|
|
207
|
+
// todo 需要考虑一种精准控制缓存的方式,仅在全局组件发生变更时才使相关使用方的缓存失效,例如按需在相关模块上动态添加request query?
|
|
208
|
+
this._module.addPresentationalDependency(new RecordGlobalComponentsDependency(mpx.usingComponents, this.context))
|
|
199
209
|
}
|
|
200
210
|
|
|
201
211
|
const processComponents = (components, context, callback) => {
|
|
202
212
|
if (components) {
|
|
203
213
|
async.eachOf(components, (component, name, callback) => {
|
|
204
|
-
processComponent(component, context, { relativePath }, (err, entry) => {
|
|
214
|
+
processComponent(component, context, { relativePath }, (err, entry, root, placeholder) => {
|
|
205
215
|
if (err === RESOLVE_IGNORED_ERR) {
|
|
206
216
|
delete components[name]
|
|
207
217
|
return callback()
|
|
208
218
|
}
|
|
209
219
|
if (err) return callback(err)
|
|
210
220
|
components[name] = entry
|
|
211
|
-
|
|
221
|
+
if (root) {
|
|
222
|
+
if (placeholder) {
|
|
223
|
+
placeholder = normalizePlaceholder(placeholder)
|
|
224
|
+
if (placeholder.resource) {
|
|
225
|
+
processComponent(placeholder.resource, projectRoot, { relativePath }, (err, entry) => {
|
|
226
|
+
if (err) return callback(err)
|
|
227
|
+
fillInComponentPlaceholder(name, placeholder.name, entry)
|
|
228
|
+
callback()
|
|
229
|
+
})
|
|
230
|
+
} else {
|
|
231
|
+
fillInComponentPlaceholder(name, placeholder.name)
|
|
232
|
+
callback()
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
if (!json.componentPlaceholder || !json.componentPlaceholder[name]) {
|
|
236
|
+
const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
|
|
237
|
+
emitError(errMsg)
|
|
238
|
+
}
|
|
239
|
+
callback()
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
callback()
|
|
243
|
+
}
|
|
212
244
|
})
|
|
213
245
|
}, callback)
|
|
214
246
|
} else {
|
|
@@ -221,14 +253,20 @@ module.exports = function (content) {
|
|
|
221
253
|
const localPages = []
|
|
222
254
|
const subPackagesCfg = {}
|
|
223
255
|
const pageKeySet = new Set()
|
|
224
|
-
|
|
256
|
+
const defaultPagePath = require.resolve('../runtime/components/wx/default-page.mpx')
|
|
225
257
|
const processPages = (pages, context, tarRoot = '', callback) => {
|
|
226
258
|
if (pages) {
|
|
259
|
+
const pagesCache = []
|
|
227
260
|
async.each(pages, (page, callback) => {
|
|
228
|
-
processPage(page, context, tarRoot, (err, entry, { isFirst, key } = {}) => {
|
|
261
|
+
processPage(page, context, tarRoot, (err, entry, { isFirst, key, resource } = {}) => {
|
|
229
262
|
if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
|
|
230
263
|
if (pageKeySet.has(key)) return callback()
|
|
264
|
+
if (resource.startsWith(defaultPagePath)) {
|
|
265
|
+
pagesCache.push(entry)
|
|
266
|
+
return callback()
|
|
267
|
+
}
|
|
231
268
|
pageKeySet.add(key)
|
|
269
|
+
|
|
232
270
|
if (tarRoot && subPackagesCfg) {
|
|
233
271
|
subPackagesCfg[tarRoot].pages.push(entry)
|
|
234
272
|
} else {
|
|
@@ -241,7 +279,18 @@ module.exports = function (content) {
|
|
|
241
279
|
}
|
|
242
280
|
callback()
|
|
243
281
|
})
|
|
244
|
-
},
|
|
282
|
+
}, () => {
|
|
283
|
+
if (tarRoot && subPackagesCfg) {
|
|
284
|
+
if (!subPackagesCfg[tarRoot].pages.length && pagesCache[0]) {
|
|
285
|
+
subPackagesCfg[tarRoot].pages.push(pagesCache[0])
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
if (!localPages.length && pagesCache[0]) {
|
|
289
|
+
localPages.push(pagesCache[0])
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
callback()
|
|
293
|
+
})
|
|
245
294
|
} else {
|
|
246
295
|
callback()
|
|
247
296
|
}
|
package/lib/loader.js
CHANGED
|
@@ -120,7 +120,6 @@ module.exports = function (content) {
|
|
|
120
120
|
|
|
121
121
|
let usingComponents = [].concat(Object.keys(mpx.usingComponents))
|
|
122
122
|
let componentPlaceholder = []
|
|
123
|
-
|
|
124
123
|
let componentGenerics = {}
|
|
125
124
|
|
|
126
125
|
if (parts.json && parts.json.content) {
|
|
@@ -134,18 +133,12 @@ module.exports = function (content) {
|
|
|
134
133
|
}
|
|
135
134
|
if (!isApp) {
|
|
136
135
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
137
|
-
// polyfill global usingComponents
|
|
138
|
-
// 预读json时无需注入polyfill全局组件
|
|
139
|
-
// rulesRunnerOptions.data = {
|
|
140
|
-
// globalComponents: mpx.usingComponents
|
|
141
|
-
// }
|
|
142
136
|
}
|
|
143
|
-
|
|
137
|
+
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
144
138
|
try {
|
|
145
139
|
const ret = JSON5.parse(parts.json.content)
|
|
140
|
+
if (rulesRunner) rulesRunner(ret)
|
|
146
141
|
if (ret.usingComponents) {
|
|
147
|
-
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
148
|
-
if (rulesRunner) rulesRunner(ret)
|
|
149
142
|
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
150
143
|
}
|
|
151
144
|
if (ret.componentPlaceholder) {
|
|
@@ -287,7 +280,7 @@ module.exports = function (content) {
|
|
|
287
280
|
let ctor = 'App'
|
|
288
281
|
if (ctorType === 'page') {
|
|
289
282
|
// swan也默认使用Page构造器
|
|
290
|
-
if (mpx.forceUsePageCtor || mode === 'ali'
|
|
283
|
+
if (mpx.forceUsePageCtor || mode === 'ali') {
|
|
291
284
|
ctor = 'Page'
|
|
292
285
|
} else {
|
|
293
286
|
ctor = 'Component'
|
package/lib/native-loader.js
CHANGED
|
@@ -8,7 +8,7 @@ const async = require('async')
|
|
|
8
8
|
const { matchCondition } = require('./utils/match-condition')
|
|
9
9
|
const { JSON_JS_EXT } = require('./utils/const')
|
|
10
10
|
const getRulesRunner = require('./platform')
|
|
11
|
-
|
|
11
|
+
// todo native-loader考虑与mpx-loader或加强复用,原生组件约等于4个区块都为src的.mpx文件
|
|
12
12
|
module.exports = function (content) {
|
|
13
13
|
this.cacheable()
|
|
14
14
|
|
|
@@ -44,6 +44,8 @@ module.exports = function (content) {
|
|
|
44
44
|
scss: '.scss'
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const TS_EXT = '.ts'
|
|
48
|
+
|
|
47
49
|
let useJSONJS = false
|
|
48
50
|
let cssLang = ''
|
|
49
51
|
const hasScoped = (queryObj.scoped || autoScope) && mode === 'ali'
|
|
@@ -54,7 +56,7 @@ module.exports = function (content) {
|
|
|
54
56
|
this.resolve(parsed.dir, resourceName + extName, callback)
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
function
|
|
59
|
+
function checkCSSLangFile (callback) {
|
|
58
60
|
const langs = mpx.nativeConfig.cssLangs || ['less', 'stylus', 'scss', 'sass']
|
|
59
61
|
const results = []
|
|
60
62
|
async.eachOf(langs, function (lang, i, callback) {
|
|
@@ -89,6 +91,15 @@ module.exports = function (content) {
|
|
|
89
91
|
})
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
function checkTSFile (callback) {
|
|
95
|
+
checkFileExists(TS_EXT, (err, result) => {
|
|
96
|
+
if (!err && result) {
|
|
97
|
+
typeResourceMap.script = result
|
|
98
|
+
}
|
|
99
|
+
callback()
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
const emitWarning = (msg) => {
|
|
93
104
|
this.emitWarning(
|
|
94
105
|
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
@@ -105,15 +116,16 @@ module.exports = function (content) {
|
|
|
105
116
|
async.waterfall([
|
|
106
117
|
(callback) => {
|
|
107
118
|
async.parallel([
|
|
108
|
-
|
|
109
|
-
checkJSONJSFile
|
|
119
|
+
checkCSSLangFile,
|
|
120
|
+
checkJSONJSFile,
|
|
121
|
+
checkTSFile
|
|
110
122
|
], (err) => {
|
|
111
123
|
callback(err)
|
|
112
124
|
})
|
|
113
125
|
},
|
|
114
126
|
(callback) => {
|
|
115
127
|
async.forEachOf(typeExtMap, (ext, key, callback) => {
|
|
116
|
-
//
|
|
128
|
+
// 对应资源存在预处理类型文件时跳过对应的标准文件检测
|
|
117
129
|
if (typeResourceMap[key]) {
|
|
118
130
|
return callback()
|
|
119
131
|
}
|
|
@@ -137,6 +149,7 @@ module.exports = function (content) {
|
|
|
137
149
|
} catch (e) {
|
|
138
150
|
return callback(e)
|
|
139
151
|
}
|
|
152
|
+
let usingComponents = Object.keys(mpx.usingComponents)
|
|
140
153
|
const rulesRunnerOptions = {
|
|
141
154
|
mode,
|
|
142
155
|
srcMode,
|
|
@@ -147,16 +160,10 @@ module.exports = function (content) {
|
|
|
147
160
|
}
|
|
148
161
|
if (!isApp) {
|
|
149
162
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
150
|
-
// polyfill global usingComponents
|
|
151
|
-
// 预读json时无需注入polyfill全局组件
|
|
152
|
-
// rulesRunnerOptions.data = {
|
|
153
|
-
// globalComponents: mpx.usingComponents
|
|
154
|
-
// }
|
|
155
163
|
}
|
|
156
|
-
|
|
164
|
+
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
165
|
+
if (rulesRunner) rulesRunner(json)
|
|
157
166
|
if (json.usingComponents) {
|
|
158
|
-
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
159
|
-
if (rulesRunner) rulesRunner(json)
|
|
160
167
|
usingComponents = usingComponents.concat(Object.keys(json.usingComponents))
|
|
161
168
|
}
|
|
162
169
|
const {
|
|
@@ -207,7 +214,7 @@ module.exports = function (content) {
|
|
|
207
214
|
let ctorType = 'app'
|
|
208
215
|
if (pagesMap[resourcePath]) {
|
|
209
216
|
ctorType = 'page'
|
|
210
|
-
if (mpx.forceUsePageCtor || mode === 'ali'
|
|
217
|
+
if (mpx.forceUsePageCtor || mode === 'ali') {
|
|
211
218
|
ctor = 'Page'
|
|
212
219
|
} else {
|
|
213
220
|
ctor = 'Component'
|
|
@@ -3,6 +3,7 @@ const normalizeTest = require('../normalize-test')
|
|
|
3
3
|
const changeKey = require('../change-key')
|
|
4
4
|
const normalize = require('../../../utils/normalize')
|
|
5
5
|
const { capitalToHyphen } = require('../../../utils/string')
|
|
6
|
+
const { isOriginTag, isBuildInTag } = require('../../../utils/dom-tag-config')
|
|
6
7
|
|
|
7
8
|
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
8
9
|
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
@@ -70,6 +71,26 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
70
71
|
return input
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// 校验输出支付宝 componentGenerics 配置的正确性
|
|
75
|
+
function aliComponentGenericsValidate (input) {
|
|
76
|
+
const componentGenerics = input.componentGenerics
|
|
77
|
+
if (componentGenerics && typeof componentGenerics === 'object') {
|
|
78
|
+
Object.keys(componentGenerics).forEach(key => {
|
|
79
|
+
if (!componentGenerics[key].default) {
|
|
80
|
+
error(`Ali environment componentGenerics need to specify a default custom component! please check the configuration of component ${key}`)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
return input
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fillGlobalComponents (input, { globalComponents }) {
|
|
88
|
+
if (globalComponents) {
|
|
89
|
+
Object.assign(globalComponents, input.usingComponents)
|
|
90
|
+
}
|
|
91
|
+
return input
|
|
92
|
+
}
|
|
93
|
+
|
|
73
94
|
// 处理 ali swan 的组件名大写字母转连字符:WordExample/wordExample -> word-example
|
|
74
95
|
function componentNameCapitalToHyphen (type) {
|
|
75
96
|
return function (input) {
|
|
@@ -105,10 +126,30 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
105
126
|
}
|
|
106
127
|
}
|
|
107
128
|
|
|
129
|
+
/**
|
|
130
|
+
* 将小程序代码中使用的与原生 HTML tag 或 内建组件 同名的组件进行转化,以解决与原生tag命名冲突问题。
|
|
131
|
+
* @param {string} type usingComponents
|
|
132
|
+
* @returns input
|
|
133
|
+
*/
|
|
134
|
+
function webHTMLTagProcesser (type) {
|
|
135
|
+
return function (input) {
|
|
136
|
+
const usingComponents = input[type]
|
|
137
|
+
if (usingComponents) {
|
|
138
|
+
Object.keys(usingComponents).forEach(tag => {
|
|
139
|
+
if (isOriginTag(tag) || isBuildInTag(tag)) {
|
|
140
|
+
usingComponents[`mpx-com-${tag}`] = usingComponents[tag]
|
|
141
|
+
delete usingComponents[tag]
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
return input
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
108
149
|
const componentRules = [
|
|
109
150
|
{
|
|
110
151
|
test: 'componentGenerics',
|
|
111
|
-
ali:
|
|
152
|
+
ali: aliComponentGenericsValidate
|
|
112
153
|
},
|
|
113
154
|
{
|
|
114
155
|
test: 'componentPlaceholder',
|
|
@@ -117,6 +158,10 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
117
158
|
tt: deletePath(),
|
|
118
159
|
jd: deletePath()
|
|
119
160
|
},
|
|
161
|
+
{
|
|
162
|
+
test: 'usingComponents',
|
|
163
|
+
web: webHTMLTagProcesser('usingComponents')
|
|
164
|
+
},
|
|
120
165
|
{
|
|
121
166
|
test: 'usingComponents',
|
|
122
167
|
ali: componentNameCapitalToHyphen('usingComponents'),
|
|
@@ -217,7 +262,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
217
262
|
}
|
|
218
263
|
|
|
219
264
|
const spec = {
|
|
220
|
-
supportedModes: ['ali', 'swan', 'qq', 'tt', 'jd', 'qa', 'dd'],
|
|
265
|
+
supportedModes: ['ali', 'swan', 'qq', 'tt', 'jd', 'qa', 'dd', 'web'],
|
|
221
266
|
normalizeTest,
|
|
222
267
|
page: [
|
|
223
268
|
...windowRules,
|
|
@@ -318,6 +363,24 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
318
363
|
tt: deletePath(),
|
|
319
364
|
jd: deletePath(true)
|
|
320
365
|
},
|
|
366
|
+
{
|
|
367
|
+
test: 'usingComponents',
|
|
368
|
+
web: webHTMLTagProcesser('usingComponents')
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
test: 'usingComponents',
|
|
372
|
+
ali: componentNameCapitalToHyphen('usingComponents'),
|
|
373
|
+
swan: componentNameCapitalToHyphen('usingComponents')
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
test: 'usingComponents',
|
|
377
|
+
// todo ali 2.0已支持全局组件,待移除
|
|
378
|
+
ali: fillGlobalComponents,
|
|
379
|
+
qq: fillGlobalComponents,
|
|
380
|
+
swan: fillGlobalComponents,
|
|
381
|
+
tt: fillGlobalComponents,
|
|
382
|
+
jd: fillGlobalComponents
|
|
383
|
+
},
|
|
321
384
|
{
|
|
322
385
|
test: 'usingComponents',
|
|
323
386
|
// todo ali 2.0已支持全局组件,待移除
|
|
@@ -11,6 +11,8 @@ module.exports = function normalizeComponentRules (cfgs, spec) {
|
|
|
11
11
|
if (cfg.test) {
|
|
12
12
|
result.test = cfg.test
|
|
13
13
|
}
|
|
14
|
+
// 透传 waterfall 信息
|
|
15
|
+
if (cfg.waterfall) result.waterfall = cfg.waterfall
|
|
14
16
|
const supportedModes = cfg.supportedModes || spec.supportedModes
|
|
15
17
|
// 合并component-config中组件的event 与index中公共的event规则
|
|
16
18
|
const eventRules = (cfg.event || []).concat(spec.event.rules)
|
|
@@ -14,7 +14,7 @@ web的额外逻辑,因为小程序组件和web存在差异,比如事件相
|
|
|
14
14
|
|
|
15
15
|
Mpx的转换一个重要原则是转不了的东西通过控制台打印提示用户,要求用户提供一份符合对应平台的代码通过条件编译支持。因此错误输出格式保持一致是有必要的。
|
|
16
16
|
|
|
17
|
-
在 index.js 中,会汇总每个组件的转换规则函数,为了使错误信息标准化,一致化,错误打印函数的生成函数实现在index.js里。
|
|
17
|
+
在 index.web.js 中,会汇总每个组件的转换规则函数,为了使错误信息标准化,一致化,错误打印函数的生成函数实现在index.js里。
|
|
18
18
|
|
|
19
19
|
每个组件文件是一个方法,接受错误打印生成方法,根据组件名生成对应的错误打印方法。
|
|
20
20
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')
|
|
2
|
+
|
|
3
|
+
module.exports = function () {
|
|
4
|
+
return {
|
|
5
|
+
waterfall: true,
|
|
6
|
+
test: (input) => isOriginTag(input) || isBuildInTag(input),
|
|
7
|
+
// 处理原生tag
|
|
8
|
+
web (tag, data = {}) {
|
|
9
|
+
// @see packages/webpack-plugin/lib/platform/json/wx/index.js webHTMLTagProcesser
|
|
10
|
+
const newTag = `mpx-com-${tag}`
|
|
11
|
+
const usingComponents = data.usingComponents || []
|
|
12
|
+
// 存在同名组件,则返回新tag
|
|
13
|
+
if (usingComponents.includes(newTag)) return newTag
|
|
14
|
+
return tag
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
const { capitalToHyphen } = require('../../../../utils/string')
|
|
2
2
|
|
|
3
3
|
module.exports = function () {
|
|
4
|
-
function convertTagName (name) {
|
|
5
|
-
return capitalToHyphen(name)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
4
|
return {
|
|
9
5
|
// tag name contains capital letters
|
|
10
6
|
test: /[A-Z]/,
|
|
11
|
-
ali:
|
|
12
|
-
swan:
|
|
7
|
+
ali: capitalToHyphen,
|
|
8
|
+
swan: capitalToHyphen
|
|
13
9
|
}
|
|
14
10
|
}
|
|
@@ -8,7 +8,7 @@ const checkbox = require('./checkbox')
|
|
|
8
8
|
const coverImage = require('./cover-image')
|
|
9
9
|
const coverView = require('./cover-view')
|
|
10
10
|
const form = require('./form')
|
|
11
|
-
const
|
|
11
|
+
const hyphenTagName = require('./hypen-tag-name')
|
|
12
12
|
const icon = require('./icon')
|
|
13
13
|
const image = require('./image')
|
|
14
14
|
const input = require('./input')
|
|
@@ -39,6 +39,7 @@ const view = require('./view')
|
|
|
39
39
|
const webView = require('./web-view')
|
|
40
40
|
const wxs = require('./wxs')
|
|
41
41
|
const component = require('./component')
|
|
42
|
+
const fixHTMLTag = require('./fix-html-tag')
|
|
42
43
|
|
|
43
44
|
module.exports = function getComponentConfigs ({ warn, error }) {
|
|
44
45
|
/**
|
|
@@ -79,6 +80,7 @@ module.exports = function getComponentConfigs ({ warn, error }) {
|
|
|
79
80
|
|
|
80
81
|
// 转换规则只需以微信为基准配置微信和支付宝的差异部分,比如微信和支付宝都支持但是写法不一致,或者微信支持而支付宝不支持的部分(抛出错误或警告)
|
|
81
82
|
return [
|
|
83
|
+
fixHTMLTag(),
|
|
82
84
|
...Nonsupport({ print }),
|
|
83
85
|
ad({ print }),
|
|
84
86
|
view({ print }),
|
|
@@ -118,7 +120,7 @@ module.exports = function getComponentConfigs ({ warn, error }) {
|
|
|
118
120
|
camera({ print }),
|
|
119
121
|
livePlayer({ print }),
|
|
120
122
|
livePusher({ print }),
|
|
121
|
-
|
|
123
|
+
hyphenTagName({ print }),
|
|
122
124
|
component()
|
|
123
125
|
]
|
|
124
126
|
}
|
|
@@ -41,18 +41,7 @@ module.exports = function ({ print }) {
|
|
|
41
41
|
// 快应用通用事件有touchstart|touchmove|touchend|touchcancel|longpress|click|focus|blur
|
|
42
42
|
event: [
|
|
43
43
|
{
|
|
44
|
-
// 支付宝中的view组件额外支持了transitionEnd|animationStart|animationIteration|animationEnd,故在此声明了组件事件转换逻辑
|
|
45
44
|
test: /^(transitionend|animationstart|animationiteration|animationend)$/,
|
|
46
|
-
//
|
|
47
|
-
ali (eventName) {
|
|
48
|
-
const eventMap = {
|
|
49
|
-
transitionend: 'transitionEnd',
|
|
50
|
-
animationstart: 'animationStart',
|
|
51
|
-
animationiteration: 'animationIteration',
|
|
52
|
-
animationend: 'animationEnd'
|
|
53
|
-
}
|
|
54
|
-
return eventMap[eventName]
|
|
55
|
-
},
|
|
56
45
|
qa: qaEventLogError
|
|
57
46
|
}
|
|
58
47
|
]
|