@mpxjs/webpack-plugin 2.8.31 → 2.8.33
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/json-compiler/helper.js +1 -1
- package/lib/json-compiler/index.js +17 -11
- package/lib/loader.js +33 -2
- package/lib/native-loader.js +31 -2
- package/lib/platform/json/wx/index.js +164 -188
- package/lib/runtime/i18n.wxs +3 -1
- package/lib/wxml/loader.js +6 -4
- package/package.json +3 -3
- package/lib/utils/fix-swan-relative.js +0 -6
- package/lib/utils/fix-using-component.js +0 -23
|
@@ -94,7 +94,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
94
94
|
aliasPath = page.path
|
|
95
95
|
page = page.src
|
|
96
96
|
}
|
|
97
|
-
if (!isUrlRequest(page)) return callback(null, page)
|
|
97
|
+
if (!isUrlRequest(page)) return callback(null, page, { key: page })
|
|
98
98
|
if (resolveMode === 'native') {
|
|
99
99
|
page = urlToRequest(page)
|
|
100
100
|
}
|
|
@@ -5,7 +5,6 @@ const parseComponent = require('../parser')
|
|
|
5
5
|
const config = require('../config')
|
|
6
6
|
const parseRequest = require('../utils/parse-request')
|
|
7
7
|
const evalJSONJS = require('../utils/eval-json-js')
|
|
8
|
-
const fixUsingComponent = require('../utils/fix-using-component')
|
|
9
8
|
const getRulesRunner = require('../platform/index')
|
|
10
9
|
const addQuery = require('../utils/add-query')
|
|
11
10
|
const getJSONContent = require('../utils/get-json-content')
|
|
@@ -143,9 +142,18 @@ module.exports = function (content) {
|
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
// 校验异步组件占位符 componentPlaceholder 不为空
|
|
146
|
+
const { usingComponents, componentPlaceholder = {} } = json
|
|
147
|
+
if (usingComponents) {
|
|
148
|
+
for (const compName in usingComponents) {
|
|
149
|
+
const compPath = usingComponents[compName]
|
|
150
|
+
if (!/\?root=/g.test(compPath)) continue
|
|
151
|
+
const compPlaceholder = componentPlaceholder[compName]
|
|
152
|
+
if (!compPlaceholder) {
|
|
153
|
+
const errMsg = `componentPlaceholder of "${compName}" doesn't exist! \n\r`
|
|
154
|
+
emitError(errMsg)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
// 快应用补全json配置,必填项
|
|
@@ -163,7 +171,6 @@ module.exports = function (content) {
|
|
|
163
171
|
|
|
164
172
|
const rulesRunnerOptions = {
|
|
165
173
|
mode,
|
|
166
|
-
mpx,
|
|
167
174
|
srcMode,
|
|
168
175
|
type: 'json',
|
|
169
176
|
waterfall: true,
|
|
@@ -173,15 +180,9 @@ module.exports = function (content) {
|
|
|
173
180
|
if (!isApp) {
|
|
174
181
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
175
182
|
// polyfill global usingComponents
|
|
176
|
-
// todo 传入rulesRunner中进行按平台转换
|
|
177
183
|
rulesRunnerOptions.data = {
|
|
178
184
|
globalComponents: mpx.usingComponents
|
|
179
185
|
}
|
|
180
|
-
} else {
|
|
181
|
-
// 保存全局注册组件
|
|
182
|
-
if (json.usingComponents) {
|
|
183
|
-
this._module.addPresentationalDependency(new RecordGlobalComponentsDependency(json.usingComponents, this.context))
|
|
184
|
-
}
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
@@ -190,6 +191,11 @@ module.exports = function (content) {
|
|
|
190
191
|
rulesRunner(json)
|
|
191
192
|
}
|
|
192
193
|
|
|
194
|
+
if (isApp && json.usingComponents) {
|
|
195
|
+
// 在 rulesRunner 运行后保存全局注册组件
|
|
196
|
+
this._module.addPresentationalDependency(new RecordGlobalComponentsDependency(json.usingComponents, this.context))
|
|
197
|
+
}
|
|
198
|
+
|
|
193
199
|
const processComponents = (components, context, callback) => {
|
|
194
200
|
if (components) {
|
|
195
201
|
async.eachOf(components, (component, name, callback) => {
|
package/lib/loader.js
CHANGED
|
@@ -4,7 +4,6 @@ const createHelpers = require('./helpers')
|
|
|
4
4
|
const loaderUtils = require('loader-utils')
|
|
5
5
|
const parseRequest = require('./utils/parse-request')
|
|
6
6
|
const { matchCondition } = require('./utils/match-condition')
|
|
7
|
-
const fixUsingComponent = require('./utils/fix-using-component')
|
|
8
7
|
const addQuery = require('./utils/add-query')
|
|
9
8
|
const async = require('async')
|
|
10
9
|
const processJSON = require('./web/processJSON')
|
|
@@ -21,6 +20,7 @@ const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDepen
|
|
|
21
20
|
const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
|
|
22
21
|
const { MPX_APP_MODULE_ID } = require('./utils/const')
|
|
23
22
|
const path = require('path')
|
|
23
|
+
const getRulesRunner = require('./platform')
|
|
24
24
|
|
|
25
25
|
module.exports = function (content) {
|
|
26
26
|
this.cacheable()
|
|
@@ -50,6 +50,19 @@ module.exports = function (content) {
|
|
|
50
50
|
const localSrcMode = queryObj.mode
|
|
51
51
|
const srcMode = localSrcMode || globalSrcMode
|
|
52
52
|
const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
|
|
53
|
+
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
54
|
+
|
|
55
|
+
const emitWarning = (msg) => {
|
|
56
|
+
this.emitWarning(
|
|
57
|
+
new Error('[mpx-loader][' + this.resource + ']: ' + msg)
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const emitError = (msg) => {
|
|
62
|
+
this.emitError(
|
|
63
|
+
new Error('[mpx-loader][' + this.resource + ']: ' + msg)
|
|
64
|
+
)
|
|
65
|
+
}
|
|
53
66
|
|
|
54
67
|
let ctorType = 'app'
|
|
55
68
|
if (pagesMap[resourcePath]) {
|
|
@@ -111,10 +124,28 @@ module.exports = function (content) {
|
|
|
111
124
|
let componentGenerics = {}
|
|
112
125
|
|
|
113
126
|
if (parts.json && parts.json.content) {
|
|
127
|
+
const rulesRunnerOptions = {
|
|
128
|
+
mode,
|
|
129
|
+
srcMode,
|
|
130
|
+
type: 'json',
|
|
131
|
+
waterfall: true,
|
|
132
|
+
warn: emitWarning,
|
|
133
|
+
error: emitError
|
|
134
|
+
}
|
|
135
|
+
if (!isApp) {
|
|
136
|
+
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
137
|
+
// polyfill global usingComponents
|
|
138
|
+
// 预读json时无需注入polyfill全局组件
|
|
139
|
+
// rulesRunnerOptions.data = {
|
|
140
|
+
// globalComponents: mpx.usingComponents
|
|
141
|
+
// }
|
|
142
|
+
}
|
|
143
|
+
|
|
114
144
|
try {
|
|
115
145
|
const ret = JSON5.parse(parts.json.content)
|
|
116
146
|
if (ret.usingComponents) {
|
|
117
|
-
|
|
147
|
+
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
148
|
+
if (rulesRunner) rulesRunner(ret)
|
|
118
149
|
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
119
150
|
}
|
|
120
151
|
if (ret.componentPlaceholder) {
|
package/lib/native-loader.js
CHANGED
|
@@ -6,8 +6,8 @@ const createHelpers = require('./helpers')
|
|
|
6
6
|
const getJSONContent = require('./utils/get-json-content')
|
|
7
7
|
const async = require('async')
|
|
8
8
|
const { matchCondition } = require('./utils/match-condition')
|
|
9
|
-
const fixUsingComponent = require('./utils/fix-using-component')
|
|
10
9
|
const { JSON_JS_EXT } = require('./utils/const')
|
|
10
|
+
const getRulesRunner = require('./platform')
|
|
11
11
|
|
|
12
12
|
module.exports = function (content) {
|
|
13
13
|
this.cacheable()
|
|
@@ -89,6 +89,18 @@ module.exports = function (content) {
|
|
|
89
89
|
})
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
const emitWarning = (msg) => {
|
|
93
|
+
this.emitWarning(
|
|
94
|
+
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const emitError = (msg) => {
|
|
99
|
+
this.emitError(
|
|
100
|
+
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
// 先读取json获取usingComponents信息
|
|
93
105
|
async.waterfall([
|
|
94
106
|
(callback) => {
|
|
@@ -125,9 +137,26 @@ module.exports = function (content) {
|
|
|
125
137
|
} catch (e) {
|
|
126
138
|
return callback(e)
|
|
127
139
|
}
|
|
140
|
+
const rulesRunnerOptions = {
|
|
141
|
+
mode,
|
|
142
|
+
srcMode,
|
|
143
|
+
type: 'json',
|
|
144
|
+
waterfall: true,
|
|
145
|
+
warn: emitWarning,
|
|
146
|
+
error: emitError
|
|
147
|
+
}
|
|
148
|
+
if (!isApp) {
|
|
149
|
+
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
150
|
+
// polyfill global usingComponents
|
|
151
|
+
// 预读json时无需注入polyfill全局组件
|
|
152
|
+
// rulesRunnerOptions.data = {
|
|
153
|
+
// globalComponents: mpx.usingComponents
|
|
154
|
+
// }
|
|
155
|
+
}
|
|
128
156
|
let usingComponents = Object.keys(mpx.usingComponents)
|
|
129
157
|
if (json.usingComponents) {
|
|
130
|
-
|
|
158
|
+
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
159
|
+
if (rulesRunner) rulesRunner(json)
|
|
131
160
|
usingComponents = usingComponents.concat(Object.keys(json.usingComponents))
|
|
132
161
|
}
|
|
133
162
|
const {
|
|
@@ -2,6 +2,7 @@ const runRules = require('../../run-rules')
|
|
|
2
2
|
const normalizeTest = require('../normalize-test')
|
|
3
3
|
const changeKey = require('../change-key')
|
|
4
4
|
const normalize = require('../../../utils/normalize')
|
|
5
|
+
const { capitalToHyphen } = require('../../../utils/string')
|
|
5
6
|
|
|
6
7
|
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
7
8
|
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
@@ -35,6 +36,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
35
36
|
/**
|
|
36
37
|
* @desc 在app.mpx里配置usingComponents作为全局组件
|
|
37
38
|
*/
|
|
39
|
+
|
|
38
40
|
function addGlobalComponents (input, { globalComponents }) {
|
|
39
41
|
if (globalComponents) {
|
|
40
42
|
input.usingComponents = Object.assign({}, globalComponents, input.usingComponents)
|
|
@@ -44,6 +46,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
44
46
|
|
|
45
47
|
// 处理支付宝 componentPlaceholder 不支持 view、text 原生标签
|
|
46
48
|
function aliComponentPlaceholderFallback (input) {
|
|
49
|
+
// 处理 驼峰转连字符
|
|
50
|
+
input = componentNameCapitalToHyphen('componentPlaceholder')(input)
|
|
47
51
|
const componentPlaceholder = input.componentPlaceholder
|
|
48
52
|
const usingComponents = input.usingComponents || (input.usingComponents = {})
|
|
49
53
|
for (const cph in componentPlaceholder) {
|
|
@@ -66,95 +70,161 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
66
70
|
return input
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
73
|
+
// 处理 ali swan 的组件名大写字母转连字符:WordExample/wordExample -> word-example
|
|
74
|
+
function componentNameCapitalToHyphen (type) {
|
|
75
|
+
return function (input) {
|
|
76
|
+
// 百度和支付宝不支持大写组件标签名,统一转成带“-”和小写的形式。百度自带标签不会有带大写的情况
|
|
77
|
+
// 后续可能需要考虑这些平台支持 componentGenerics 后的转换 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/generics.html
|
|
78
|
+
const obj = input[type]
|
|
79
|
+
if (obj) {
|
|
80
|
+
Object.entries(obj).forEach(([k, v]) => {
|
|
81
|
+
const keyNeed = /[A-Z]/g.test(k)
|
|
82
|
+
const valueNeed = /[A-Z]/g.test(v)
|
|
83
|
+
|
|
84
|
+
let newK
|
|
85
|
+
let newV
|
|
86
|
+
|
|
87
|
+
if (keyNeed) {
|
|
88
|
+
newK = capitalToHyphen(k)
|
|
89
|
+
if (obj[newK]) {
|
|
90
|
+
warn && warn(`Component name "${newK}" already exists, so component "${k}" can't be converted automatically and it isn't supported in ali/swan environment!`)
|
|
91
|
+
} else {
|
|
92
|
+
obj[newK] = v
|
|
93
|
+
delete obj[k]
|
|
94
|
+
}
|
|
85
95
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
|
|
97
|
+
// componentPlaceholder 的 value 也需要转换
|
|
98
|
+
if (type === 'componentPlaceholder' && valueNeed) {
|
|
99
|
+
newV = capitalToHyphen(v)
|
|
100
|
+
obj[newK || k] = newV
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
return input
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const componentRules = [
|
|
109
|
+
{
|
|
110
|
+
test: 'componentGenerics',
|
|
111
|
+
ali: deletePath(true)
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
test: 'componentPlaceholder',
|
|
115
|
+
ali: aliComponentPlaceholderFallback,
|
|
116
|
+
swan: deletePath(),
|
|
117
|
+
tt: deletePath(),
|
|
118
|
+
jd: deletePath()
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
test: 'usingComponents',
|
|
122
|
+
ali: componentNameCapitalToHyphen('usingComponents'),
|
|
123
|
+
swan: componentNameCapitalToHyphen('usingComponents')
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
// todo ali 2.0已支持全局组件,待移除
|
|
127
|
+
ali: addGlobalComponents,
|
|
128
|
+
swan: addGlobalComponents,
|
|
129
|
+
qq: addGlobalComponents,
|
|
130
|
+
tt: addGlobalComponents,
|
|
131
|
+
jd: addGlobalComponents
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
const windowRules = [
|
|
136
|
+
{
|
|
137
|
+
test: 'navigationBarTitleText',
|
|
138
|
+
ali (input) {
|
|
139
|
+
return changeKey(input, this.test, 'defaultTitle')
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
test: 'enablePullDownRefresh',
|
|
144
|
+
ali (input) {
|
|
145
|
+
input = changeKey(input, this.test, 'pullRefresh')
|
|
146
|
+
if (input.pullRefresh) {
|
|
147
|
+
input.allowsBounceVertical = 'YES'
|
|
94
148
|
}
|
|
149
|
+
return input
|
|
95
150
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
test: 'onReachBottomDistance',
|
|
105
|
-
qq: deletePath(),
|
|
106
|
-
jd: deletePath()
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
test: 'disableScroll',
|
|
110
|
-
ali: deletePath(),
|
|
111
|
-
qq: deletePath(),
|
|
112
|
-
jd: deletePath()
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
test: 'backgroundColorTop|backgroundColorBottom',
|
|
116
|
-
ali: deletePath(),
|
|
117
|
-
swan: deletePath()
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
test: 'navigationBarTextStyle|navigationStyle|backgroundTextStyle',
|
|
121
|
-
ali: deletePath()
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
test: 'pageOrientation',
|
|
125
|
-
ali: deletePath(),
|
|
126
|
-
swan: deletePath(),
|
|
127
|
-
tt: deletePath(),
|
|
128
|
-
jd: deletePath()
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
test: 'componentPlaceholder',
|
|
132
|
-
ali: aliComponentPlaceholderFallback
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
ali: addGlobalComponents,
|
|
136
|
-
swan: addGlobalComponents,
|
|
137
|
-
qq: addGlobalComponents,
|
|
138
|
-
tt: addGlobalComponents,
|
|
139
|
-
jd: addGlobalComponents
|
|
151
|
+
jd: deletePath()
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
test: 'navigationBarBackgroundColor',
|
|
155
|
+
ali (input) {
|
|
156
|
+
return changeKey(input, this.test, 'titleBarColor')
|
|
140
157
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
test: 'disableSwipeBack',
|
|
161
|
+
ali: deletePath(),
|
|
162
|
+
qq: deletePath(),
|
|
163
|
+
jd: deletePath(),
|
|
164
|
+
swan: deletePath()
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
test: 'onReachBottomDistance',
|
|
168
|
+
qq: deletePath(),
|
|
169
|
+
jd: deletePath()
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
test: 'disableScroll',
|
|
173
|
+
ali: deletePath(),
|
|
174
|
+
qq: deletePath(),
|
|
175
|
+
jd: deletePath()
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
test: 'backgroundColorTop|backgroundColorBottom',
|
|
179
|
+
ali: deletePath(),
|
|
180
|
+
swan: deletePath()
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
test: 'navigationBarTextStyle|navigationStyle|backgroundTextStyle',
|
|
184
|
+
ali: deletePath()
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
test: 'pageOrientation',
|
|
188
|
+
ali: deletePath(),
|
|
189
|
+
swan: deletePath(),
|
|
190
|
+
tt: deletePath(),
|
|
191
|
+
jd: deletePath()
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
const getTabBarRule = () => (input, { mode }) => {
|
|
196
|
+
input.tabBar = runRules(spec.tabBar, input.tabBar, {
|
|
197
|
+
mode,
|
|
198
|
+
normalizeTest,
|
|
199
|
+
waterfall: true,
|
|
200
|
+
data: {
|
|
201
|
+
pathArr: ['tabBar']
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
return input
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const getWindowRule = () => (input, { mode }) => {
|
|
208
|
+
input.window = runRules(spec.window, input.window, {
|
|
209
|
+
mode,
|
|
210
|
+
normalizeTest,
|
|
211
|
+
waterfall: true,
|
|
212
|
+
data: {
|
|
213
|
+
pathArr: ['window']
|
|
156
214
|
}
|
|
215
|
+
})
|
|
216
|
+
return input
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const spec = {
|
|
220
|
+
supportedModes: ['ali', 'swan', 'qq', 'tt', 'jd', 'qa', 'dd'],
|
|
221
|
+
normalizeTest,
|
|
222
|
+
page: [
|
|
223
|
+
...windowRules,
|
|
224
|
+
...componentRules
|
|
157
225
|
],
|
|
226
|
+
component: componentRules,
|
|
227
|
+
window: windowRules,
|
|
158
228
|
tabBar: {
|
|
159
229
|
list: [
|
|
160
230
|
{
|
|
@@ -250,6 +320,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
250
320
|
},
|
|
251
321
|
{
|
|
252
322
|
test: 'usingComponents',
|
|
323
|
+
// todo ali 2.0已支持全局组件,待移除
|
|
253
324
|
ali: deletePath({ noLog: true }),
|
|
254
325
|
qq: deletePath({ noLog: true }),
|
|
255
326
|
swan: deletePath({ noLog: true }),
|
|
@@ -288,114 +359,19 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
288
359
|
},
|
|
289
360
|
{
|
|
290
361
|
test: 'tabBar',
|
|
291
|
-
ali (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
data: {
|
|
297
|
-
pathArr: ['tabBar']
|
|
298
|
-
}
|
|
299
|
-
})
|
|
300
|
-
},
|
|
301
|
-
qq (input) {
|
|
302
|
-
input.tabBar = runRules(spec.tabBar, input.tabBar, {
|
|
303
|
-
mode: 'qq',
|
|
304
|
-
normalizeTest,
|
|
305
|
-
waterfall: true,
|
|
306
|
-
data: {
|
|
307
|
-
pathArr: ['tabBar']
|
|
308
|
-
}
|
|
309
|
-
})
|
|
310
|
-
},
|
|
311
|
-
swan (input) {
|
|
312
|
-
input.tabBar = runRules(spec.tabBar, input.tabBar, {
|
|
313
|
-
mode: 'swan',
|
|
314
|
-
normalizeTest,
|
|
315
|
-
waterfall: true,
|
|
316
|
-
data: {
|
|
317
|
-
pathArr: ['tabBar']
|
|
318
|
-
}
|
|
319
|
-
})
|
|
320
|
-
},
|
|
321
|
-
tt (input) {
|
|
322
|
-
input.tabBar = runRules(spec.tabBar, input.tabBar, {
|
|
323
|
-
mode: 'tt',
|
|
324
|
-
normalizeTest,
|
|
325
|
-
waterfall: true,
|
|
326
|
-
data: {
|
|
327
|
-
pathArr: ['tabBar']
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
},
|
|
331
|
-
jd (input) {
|
|
332
|
-
input.tabBar = runRules(spec.tabBar, input.tabBar, {
|
|
333
|
-
mode: 'jd',
|
|
334
|
-
normalizeTest,
|
|
335
|
-
waterfall: true,
|
|
336
|
-
data: {
|
|
337
|
-
pathArr: ['tabBar']
|
|
338
|
-
}
|
|
339
|
-
})
|
|
340
|
-
}
|
|
362
|
+
ali: getTabBarRule(),
|
|
363
|
+
qq: getTabBarRule(),
|
|
364
|
+
swan: getTabBarRule(),
|
|
365
|
+
tt: getTabBarRule(),
|
|
366
|
+
jd: getTabBarRule()
|
|
341
367
|
},
|
|
342
368
|
{
|
|
343
369
|
test: 'window',
|
|
344
|
-
ali (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
data: {
|
|
350
|
-
pathArr: ['window']
|
|
351
|
-
}
|
|
352
|
-
})
|
|
353
|
-
return input
|
|
354
|
-
},
|
|
355
|
-
qq (input) {
|
|
356
|
-
input.window = runRules(spec.page, input.window, {
|
|
357
|
-
mode: 'qq',
|
|
358
|
-
normalizeTest,
|
|
359
|
-
waterfall: true,
|
|
360
|
-
data: {
|
|
361
|
-
pathArr: ['window']
|
|
362
|
-
}
|
|
363
|
-
})
|
|
364
|
-
return input
|
|
365
|
-
},
|
|
366
|
-
swan (input) {
|
|
367
|
-
input.window = runRules(spec.page, input.window, {
|
|
368
|
-
mode: 'swan',
|
|
369
|
-
normalizeTest,
|
|
370
|
-
waterfall: true,
|
|
371
|
-
data: {
|
|
372
|
-
pathArr: ['window']
|
|
373
|
-
}
|
|
374
|
-
})
|
|
375
|
-
return input
|
|
376
|
-
},
|
|
377
|
-
tt (input) {
|
|
378
|
-
input.window = runRules(spec.page, input.window, {
|
|
379
|
-
mode: 'tt',
|
|
380
|
-
normalizeTest,
|
|
381
|
-
waterfall: true,
|
|
382
|
-
data: {
|
|
383
|
-
pathArr: ['window']
|
|
384
|
-
}
|
|
385
|
-
})
|
|
386
|
-
return input
|
|
387
|
-
},
|
|
388
|
-
jd (input) {
|
|
389
|
-
input.window = runRules(spec.page, input.window, {
|
|
390
|
-
mode: 'jd',
|
|
391
|
-
normalizeTest,
|
|
392
|
-
waterfall: true,
|
|
393
|
-
data: {
|
|
394
|
-
pathArr: ['window']
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
return input
|
|
398
|
-
}
|
|
370
|
+
ali: getWindowRule(),
|
|
371
|
+
qq: getWindowRule(),
|
|
372
|
+
swan: getWindowRule(),
|
|
373
|
+
tt: getWindowRule(),
|
|
374
|
+
jd: getWindowRule()
|
|
399
375
|
}
|
|
400
376
|
]
|
|
401
377
|
}
|
package/lib/runtime/i18n.wxs
CHANGED
|
@@ -122,7 +122,9 @@ function compile (tokens, values) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function interpolate (message, values) {
|
|
125
|
-
|
|
125
|
+
if (!values) {
|
|
126
|
+
return [message]
|
|
127
|
+
}
|
|
126
128
|
var tokens = _tokenCaches[message]
|
|
127
129
|
if (!tokens) {
|
|
128
130
|
tokens = parseMessage(message)
|
package/lib/wxml/loader.js
CHANGED
|
@@ -6,8 +6,10 @@ const createHelpers = require('../helpers')
|
|
|
6
6
|
const isUrlRequest = require('../utils/is-url-request')
|
|
7
7
|
const parseRequest = require('../utils/parse-request')
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let count = 0
|
|
10
|
+
|
|
11
|
+
function countIdent () {
|
|
12
|
+
return `__HTMLLINK__${count++}__`
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
module.exports = function (content) {
|
|
@@ -57,7 +59,7 @@ module.exports = function (content) {
|
|
|
57
59
|
|
|
58
60
|
let ident
|
|
59
61
|
do {
|
|
60
|
-
ident =
|
|
62
|
+
ident = countIdent()
|
|
61
63
|
} while (data[ident])
|
|
62
64
|
data[ident] = link
|
|
63
65
|
const x = content.pop()
|
|
@@ -71,7 +73,7 @@ module.exports = function (content) {
|
|
|
71
73
|
|
|
72
74
|
const exportsString = 'module.exports = '
|
|
73
75
|
|
|
74
|
-
return exportsString + content.replace(/
|
|
76
|
+
return exportsString + content.replace(/__HTMLLINK__\d+__/g, (match) => {
|
|
75
77
|
if (!data[match]) return match
|
|
76
78
|
|
|
77
79
|
const link = data[match]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.33",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"url": "https://github.com/didi/mpx/issues"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
|
-
"test": "
|
|
76
|
+
"test": "jest"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@types/babel-traverse": "^6.25.4",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "6838a99375bfce3ebd8046e86f8806920f4f2b37"
|
|
86
86
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { capitalToHyphen } = require('./string')
|
|
2
|
-
|
|
3
|
-
module.exports = function (usingComponents, mode, warn) {
|
|
4
|
-
// 百度和支付宝不支持大写组件标签名,统一转成带“-”和小写的形式。百度自带标签不会有带大写的情况
|
|
5
|
-
// 后续可能需要考虑这些平台支持 componentGenerics 后的转换 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/generics.html
|
|
6
|
-
const usingDashMode = ['ali', 'swan'] // 使用连字符标签名的mode
|
|
7
|
-
if (usingComponents) {
|
|
8
|
-
if (usingDashMode.includes(mode)) {
|
|
9
|
-
Object.keys(usingComponents).forEach(k => {
|
|
10
|
-
const newK = capitalToHyphen(k)
|
|
11
|
-
if (newK !== k) {
|
|
12
|
-
if (usingComponents[newK]) {
|
|
13
|
-
warn && warn(`Component name "${newK}" already exists, so component "${k}" can't be converted automatically and it isn't supported in ali/swan environment!`)
|
|
14
|
-
} else {
|
|
15
|
-
usingComponents[newK] = usingComponents[k]
|
|
16
|
-
delete usingComponents[k]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return usingComponents
|
|
23
|
-
}
|