@mpxjs/webpack-plugin 2.6.114-alpha.8 → 2.6.115
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/README.md +1 -1
- package/lib/built-in-loader.js +49 -0
- package/lib/config.js +0 -14
- package/lib/content-loader.js +13 -0
- package/lib/dependency/ChildCompileDependency.js +24 -0
- package/lib/dependency/InjectDependency.js +26 -0
- package/lib/dependency/RemovedModuleDependency.js +23 -0
- package/lib/{dependencies → dependency}/ReplaceDependency.js +2 -19
- package/lib/dependency/ResolveDependency.js +49 -0
- package/lib/extractor.js +178 -82
- package/lib/file-loader.js +19 -7
- package/lib/helpers.js +334 -39
- package/lib/index.js +525 -889
- package/lib/json-compiler/index.js +451 -245
- package/lib/json-compiler/{theme.js → theme-loader.js} +3 -5
- package/lib/loader.js +241 -178
- package/lib/native-loader.js +133 -71
- package/lib/parser.js +2 -1
- package/lib/path-loader.js +3 -0
- package/lib/platform/json/wx/index.js +1 -1
- package/lib/platform/template/normalize-component-rules.js +3 -2
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/rich-text.js +0 -4
- package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +3 -149
- package/lib/plugin-loader.js +287 -0
- package/lib/resolver/AddEnvPlugin.js +3 -4
- package/lib/resolver/AddModePlugin.js +3 -4
- package/lib/resolver/PackageEntryPlugin.js +36 -23
- package/lib/runtime/base.styl +0 -5
- package/lib/runtime/components/web/getInnerListeners.js +3 -1
- package/lib/runtime/components/web/mpx-image.vue +5 -20
- package/lib/runtime/components/web/mpx-movable-view.vue +2 -6
- package/lib/runtime/components/web/mpx-swiper.vue +3 -18
- package/lib/runtime/i18n.wxs +11 -31
- package/lib/runtime/optionProcessor.js +3 -48
- package/lib/selector.js +10 -29
- package/lib/staticConfig.js +4 -0
- package/lib/style-compiler/index.js +24 -16
- package/lib/style-compiler/load-postcss-config.js +1 -3
- package/lib/style-compiler/plugins/conditional-strip.js +65 -68
- package/lib/style-compiler/plugins/rpx.js +37 -43
- package/lib/style-compiler/plugins/scope-id.js +72 -79
- package/lib/style-compiler/plugins/trans-special.js +18 -25
- package/lib/style-compiler/plugins/trim.js +7 -13
- package/lib/style-compiler/plugins/vw.js +16 -22
- package/lib/template-compiler/compiler.js +199 -106
- package/lib/template-compiler/index.js +139 -52
- package/lib/template-compiler/trans-dynamic-class-expr.js +13 -18
- package/lib/url-loader.js +29 -11
- package/lib/utils/add-query.js +1 -1
- package/lib/utils/get-main-compilation.js +6 -0
- package/lib/utils/is-url-request.js +1 -10
- package/lib/utils/match-condition.js +1 -4
- package/lib/utils/normalize.js +15 -4
- package/lib/utils/parse-request.js +3 -3
- package/lib/utils/read-json-for-src.js +34 -0
- package/lib/utils/stringify-query.js +0 -4
- package/lib/utils/try-require.js +16 -0
- package/lib/web/processJSON.js +144 -113
- package/lib/web/processScript.js +34 -47
- package/lib/web/processTemplate.js +40 -57
- package/lib/wxml/{loader.js → wxml-loader.js} +62 -21
- package/lib/wxs/WxsParserPlugin.js +2 -2
- package/lib/wxs/WxsPlugin.js +8 -4
- package/lib/wxs/WxsTemplatePlugin.js +92 -46
- package/lib/wxs/{i18n-loader.js → wxs-i18n-loader.js} +4 -5
- package/lib/wxs/wxs-loader.js +117 -0
- package/lib/wxs/{pre-loader.js → wxs-pre-loader.js} +5 -20
- package/lib/wxss/getImportPrefix.js +30 -0
- package/lib/wxss/loader.js +43 -31
- package/lib/wxss/localsLoader.js +5 -1
- package/lib/wxss/processCss.js +103 -107
- package/package.json +18 -21
- package/LICENSE +0 -433
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/dependencies/AppEntryDependency.js +0 -58
- package/lib/dependencies/CommonJsAsyncDependency.js +0 -51
- package/lib/dependencies/CommonJsVariableDependency.js +0 -81
- package/lib/dependencies/DynamicEntryDependency.js +0 -171
- package/lib/dependencies/FlagPluginDependency.js +0 -24
- package/lib/dependencies/InjectDependency.js +0 -43
- package/lib/dependencies/RecordGlobalComponentsDependency.js +0 -50
- package/lib/dependencies/RecordIndependentDependency.js +0 -44
- package/lib/dependencies/RecordResourceMapDependency.js +0 -62
- package/lib/dependencies/RemoveEntryDependency.js +0 -40
- package/lib/dependencies/ResolveDependency.js +0 -88
- package/lib/independent-loader.js +0 -52
- package/lib/json-compiler/helper.js +0 -156
- package/lib/json-compiler/plugin.js +0 -150
- package/lib/partial-compile/index.js +0 -35
- package/lib/record-loader.js +0 -11
- package/lib/resolve-loader.js +0 -6
- package/lib/resolver/FixDescriptionInfoPlugin.js +0 -28
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -317
- package/lib/runtime/components/tenon/tenon-button.vue +0 -305
- package/lib/runtime/components/tenon/tenon-image.vue +0 -61
- package/lib/runtime/components/tenon/tenon-input.vue +0 -99
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -21
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -124
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -91
- package/lib/runtime/components/tenon/tenon-text-area.vue +0 -64
- package/lib/runtime/components/tenon/tenon-text.vue +0 -64
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/tenon/util.js +0 -44
- package/lib/runtime/optionProcessor.tenon.js +0 -386
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -105
- package/lib/tenon/processJSON.js +0 -360
- package/lib/tenon/processScript.js +0 -260
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -133
- package/lib/utils/const.js +0 -10
- package/lib/utils/emit-file.js +0 -10
- package/lib/utils/eval-json-js.js +0 -31
- package/lib/utils/get-entry-name.js +0 -13
- package/lib/utils/get-json-content.js +0 -42
- package/lib/utils/get-relative-path.js +0 -24
- package/lib/utils/resolve.js +0 -13
- package/lib/utils/set.js +0 -47
- package/lib/utils/stringify-loaders-resource.js +0 -25
- package/lib/wxs/WxsModuleIdsPlugin.js +0 -29
- package/lib/wxs/loader.js +0 -142
package/lib/native-loader.js
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const JSON5 = require('json5')
|
|
3
3
|
const parseRequest = require('./utils/parse-request')
|
|
4
|
+
const loaderUtils = require('loader-utils')
|
|
4
5
|
const config = require('./config')
|
|
5
6
|
const createHelpers = require('./helpers')
|
|
6
|
-
const
|
|
7
|
+
const InjectDependency = require('./dependency/InjectDependency')
|
|
8
|
+
const addQuery = require('./utils/add-query')
|
|
9
|
+
const mpxJSON = require('./utils/mpx-json')
|
|
7
10
|
const async = require('async')
|
|
8
|
-
const
|
|
11
|
+
const matchCondition = require('./utils/match-condition')
|
|
9
12
|
const fixUsingComponent = require('./utils/fix-using-component')
|
|
10
|
-
const
|
|
13
|
+
const getMainCompilation = require('./utils/get-main-compilation')
|
|
11
14
|
|
|
12
15
|
module.exports = function (content) {
|
|
13
16
|
this.cacheable()
|
|
14
17
|
|
|
15
|
-
const
|
|
18
|
+
const mainCompilation = getMainCompilation(this._compilation)
|
|
19
|
+
const mpx = mainCompilation.__mpx__
|
|
16
20
|
if (!mpx) {
|
|
17
21
|
return content
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const nativeCallback = this.async()
|
|
25
|
+
|
|
21
26
|
const loaderContext = this
|
|
22
27
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
28
|
+
const options = Object.assign({}, mpx.loaderOptions, loaderUtils.getOptions(this))
|
|
29
|
+
|
|
23
30
|
const filePath = this.resourcePath
|
|
31
|
+
|
|
24
32
|
const moduleId = 'm' + mpx.pathHash(filePath)
|
|
25
33
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
34
|
+
const projectRoot = mpx.projectRoot
|
|
26
35
|
const mode = mpx.mode
|
|
36
|
+
const defs = mpx.defs
|
|
27
37
|
const globalSrcMode = mpx.srcMode
|
|
28
38
|
const localSrcMode = queryObj.mode
|
|
29
39
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
@@ -31,12 +41,14 @@ module.exports = function (content) {
|
|
|
31
41
|
const componentsMap = mpx.componentsMap[packageName]
|
|
32
42
|
const parsed = path.parse(resourcePath)
|
|
33
43
|
const resourceName = path.join(parsed.dir, parsed.name)
|
|
34
|
-
const isApp = !
|
|
44
|
+
const isApp = !pagesMap[resourcePath] && !componentsMap[resourcePath]
|
|
35
45
|
const srcMode = localSrcMode || globalSrcMode
|
|
46
|
+
const fs = this._compiler.inputFileSystem
|
|
36
47
|
const typeExtMap = config[srcMode].typeExtMap
|
|
37
48
|
const typeResourceMap = {}
|
|
38
49
|
const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
|
|
39
50
|
|
|
51
|
+
const EXT_MPX_JSON = '.json.js'
|
|
40
52
|
const CSS_LANG_EXT_MAP = {
|
|
41
53
|
less: '.less',
|
|
42
54
|
stylus: '.styl',
|
|
@@ -44,18 +56,40 @@ module.exports = function (content) {
|
|
|
44
56
|
scss: '.scss'
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
let
|
|
59
|
+
let useMPXJSON = false
|
|
48
60
|
let cssLang = ''
|
|
49
61
|
const hasScoped = (queryObj.scoped || autoScope) && mode === 'ali'
|
|
50
62
|
const hasComment = false
|
|
51
63
|
const isNative = true
|
|
52
64
|
|
|
65
|
+
const tryEvalMPXJSON = (callback) => {
|
|
66
|
+
const { rawResourcePath } = parseRequest(typeResourceMap['json'])
|
|
67
|
+
const _src = rawResourcePath
|
|
68
|
+
this.addDependency(_src)
|
|
69
|
+
fs.readFile(_src, (err, raw) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
callback(err)
|
|
72
|
+
} else {
|
|
73
|
+
try {
|
|
74
|
+
const source = raw.toString('utf-8')
|
|
75
|
+
const text = mpxJSON.compileMPXJSONText({ source, defs, filePath: _src })
|
|
76
|
+
callback(null, text)
|
|
77
|
+
} catch (e) {
|
|
78
|
+
callback(e)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
const checkFileExists = (extName, callback) => {
|
|
54
|
-
this.resolve(parsed.dir, resourceName + extName,
|
|
85
|
+
this.resolve(parsed.dir, resourceName + extName, (err, result) => {
|
|
86
|
+
err = null
|
|
87
|
+
callback(err, result)
|
|
88
|
+
})
|
|
55
89
|
}
|
|
56
90
|
|
|
57
91
|
function checkCSSLangFiles (callback) {
|
|
58
|
-
const langs = mpx.
|
|
92
|
+
const langs = mpx.nativeOptions.cssLangs || ['less', 'stylus', 'scss', 'sass']
|
|
59
93
|
const results = []
|
|
60
94
|
async.eachOf(langs, function (lang, i, callback) {
|
|
61
95
|
if (!CSS_LANG_EXT_MAP[lang]) {
|
|
@@ -65,7 +99,7 @@ module.exports = function (content) {
|
|
|
65
99
|
if (!err && result) {
|
|
66
100
|
results[i] = result
|
|
67
101
|
}
|
|
68
|
-
callback()
|
|
102
|
+
callback(err)
|
|
69
103
|
})
|
|
70
104
|
}, function (err) {
|
|
71
105
|
for (let i = 0; i < langs.length; i++) {
|
|
@@ -79,13 +113,14 @@ module.exports = function (content) {
|
|
|
79
113
|
})
|
|
80
114
|
}
|
|
81
115
|
|
|
82
|
-
function
|
|
83
|
-
checkFileExists(
|
|
116
|
+
function checkMPXJSONFile (callback) {
|
|
117
|
+
// checkFileExists(EXT_MPX_JSON, (err, result) => {
|
|
118
|
+
checkFileExists(EXT_MPX_JSON, (err, result) => {
|
|
84
119
|
if (!err && result) {
|
|
85
120
|
typeResourceMap.json = result
|
|
86
|
-
|
|
121
|
+
useMPXJSON = true
|
|
87
122
|
}
|
|
88
|
-
callback()
|
|
123
|
+
callback(err)
|
|
89
124
|
})
|
|
90
125
|
}
|
|
91
126
|
|
|
@@ -94,111 +129,138 @@ module.exports = function (content) {
|
|
|
94
129
|
(callback) => {
|
|
95
130
|
async.parallel([
|
|
96
131
|
checkCSSLangFiles,
|
|
97
|
-
|
|
132
|
+
checkMPXJSONFile
|
|
98
133
|
], (err) => {
|
|
99
134
|
callback(err)
|
|
100
135
|
})
|
|
101
136
|
},
|
|
102
137
|
(callback) => {
|
|
103
138
|
async.forEachOf(typeExtMap, (ext, key, callback) => {
|
|
104
|
-
// 检测到
|
|
105
|
-
if (
|
|
139
|
+
// 检测到mpxJson或cssLang时跳过对应类型文件检测
|
|
140
|
+
if ((key === 'json' && useMPXJSON) || (key === 'styles' && cssLang)) {
|
|
106
141
|
return callback()
|
|
107
142
|
}
|
|
108
143
|
checkFileExists(ext, (err, result) => {
|
|
109
144
|
if (!err && result) {
|
|
110
145
|
typeResourceMap[key] = result
|
|
111
146
|
}
|
|
112
|
-
callback()
|
|
147
|
+
callback(err)
|
|
113
148
|
})
|
|
114
149
|
}, callback)
|
|
115
150
|
},
|
|
116
151
|
(callback) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
152
|
+
// 对原生写法增强json写法,可以用js来写json,尝试找.json.js文件,找不到用回json的内容
|
|
153
|
+
if (useMPXJSON) {
|
|
154
|
+
tryEvalMPXJSON(callback)
|
|
155
|
+
} else {
|
|
156
|
+
if (typeResourceMap['json']) {
|
|
157
|
+
// eslint-disable-next-line handle-callback-err
|
|
158
|
+
const { rawResourcePath } = parseRequest(typeResourceMap['json'])
|
|
159
|
+
fs.readFile(rawResourcePath, (err, raw) => {
|
|
160
|
+
if (err) {
|
|
161
|
+
callback(err)
|
|
162
|
+
} else {
|
|
163
|
+
callback(null, raw.toString('utf-8'))
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
} else {
|
|
167
|
+
callback(null, '{}')
|
|
168
|
+
}
|
|
169
|
+
}
|
|
121
170
|
}, (content, callback) => {
|
|
122
|
-
let
|
|
171
|
+
let usingComponents = [].concat(Object.keys(mpx.usingComponents))
|
|
123
172
|
try {
|
|
124
|
-
|
|
173
|
+
let ret = JSON5.parse(content)
|
|
174
|
+
if (ret.usingComponents) {
|
|
175
|
+
fixUsingComponent(ret.usingComponents, mode)
|
|
176
|
+
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
177
|
+
}
|
|
125
178
|
} catch (e) {
|
|
126
|
-
return callback(e)
|
|
127
|
-
}
|
|
128
|
-
let usingComponents = Object.keys(mpx.usingComponents)
|
|
129
|
-
if (json.usingComponents) {
|
|
130
|
-
fixUsingComponent(json.usingComponents, mode)
|
|
131
|
-
usingComponents = usingComponents.concat(Object.keys(json.usingComponents))
|
|
132
179
|
}
|
|
133
180
|
const {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
181
|
+
getRequireForSrc,
|
|
182
|
+
getNamedExportsForSrc
|
|
183
|
+
} = createHelpers({
|
|
184
|
+
loaderContext,
|
|
185
|
+
options,
|
|
186
|
+
moduleId,
|
|
187
|
+
hasScoped,
|
|
188
|
+
hasComment,
|
|
189
|
+
usingComponents,
|
|
190
|
+
srcMode,
|
|
191
|
+
isNative,
|
|
192
|
+
projectRoot
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
const getRequire = (type) => {
|
|
196
|
+
const localQuery = Object.assign({}, queryObj)
|
|
197
|
+
let src = typeResourceMap[type]
|
|
198
|
+
localQuery.resourcePath = resourcePath
|
|
199
|
+
if (type !== 'script') {
|
|
200
|
+
this.addDependency(src)
|
|
201
|
+
}
|
|
202
|
+
if (type === 'template' && isApp) {
|
|
203
|
+
return ''
|
|
204
|
+
}
|
|
205
|
+
if (type === 'json' && !useMPXJSON) {
|
|
206
|
+
localQuery.__component = true
|
|
143
207
|
}
|
|
208
|
+
src = addQuery(src, localQuery, true)
|
|
209
|
+
const partsOpts = { src }
|
|
144
210
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (isApp) return ''
|
|
148
|
-
Object.assign(extraOptions, {
|
|
149
|
-
hasScoped,
|
|
150
|
-
hasComment,
|
|
151
|
-
isNative,
|
|
152
|
-
moduleId,
|
|
153
|
-
usingComponents
|
|
154
|
-
})
|
|
155
|
-
break
|
|
156
|
-
case 'styles':
|
|
157
|
-
if (cssLang) part.lang = cssLang
|
|
158
|
-
Object.assign(extraOptions, {
|
|
159
|
-
moduleId,
|
|
160
|
-
scoped: hasScoped
|
|
161
|
-
})
|
|
162
|
-
break
|
|
163
|
-
case 'json':
|
|
164
|
-
if (useJSONJS) part.useJSONJS = true
|
|
165
|
-
break
|
|
211
|
+
if (type === 'script') {
|
|
212
|
+
return getNamedExportsForSrc(type, partsOpts)
|
|
166
213
|
}
|
|
167
|
-
|
|
214
|
+
if (type === 'styles') {
|
|
215
|
+
if (cssLang) {
|
|
216
|
+
partsOpts.lang = cssLang
|
|
217
|
+
}
|
|
218
|
+
if (hasScoped) {
|
|
219
|
+
return getRequireForSrc(type, partsOpts, 0, true)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return getRequireForSrc(type, partsOpts)
|
|
168
223
|
}
|
|
169
224
|
|
|
170
225
|
// 注入模块id及资源路径
|
|
171
|
-
let
|
|
226
|
+
let globalInjectCode = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
172
227
|
if (!isProduction) {
|
|
173
|
-
|
|
228
|
+
globalInjectCode += `global.currentResource = ${JSON.stringify(filePath)}\n`
|
|
174
229
|
}
|
|
175
230
|
|
|
176
231
|
// 注入构造函数
|
|
177
232
|
let ctor = 'App'
|
|
178
|
-
let ctorType = 'app'
|
|
179
233
|
if (pagesMap[resourcePath]) {
|
|
180
|
-
|
|
181
|
-
if (mpx.forceUsePageCtor || mode === 'ali' || mode === 'swan') {
|
|
234
|
+
if (mpx.forceUsePageCtor || mode === 'ali') {
|
|
182
235
|
ctor = 'Page'
|
|
183
236
|
} else {
|
|
184
237
|
ctor = 'Component'
|
|
185
238
|
}
|
|
186
239
|
} else if (componentsMap[resourcePath]) {
|
|
187
240
|
ctor = 'Component'
|
|
188
|
-
ctorType = 'component'
|
|
189
241
|
}
|
|
190
|
-
|
|
191
|
-
|
|
242
|
+
globalInjectCode += `global.currentCtor = ${ctor}\n`
|
|
243
|
+
globalInjectCode += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
|
|
192
244
|
return match.toLowerCase()
|
|
193
245
|
}))}\n`
|
|
194
|
-
output += `global.currentResourceType = ${JSON.stringify(ctorType)}\n`
|
|
195
246
|
|
|
196
247
|
if (srcMode) {
|
|
197
|
-
|
|
248
|
+
globalInjectCode += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
|
|
198
249
|
}
|
|
199
250
|
|
|
251
|
+
if (!mpx.forceDisableInject) {
|
|
252
|
+
const dep = new InjectDependency({
|
|
253
|
+
content: globalInjectCode,
|
|
254
|
+
index: -3
|
|
255
|
+
})
|
|
256
|
+
this._module.addDependency(dep)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// 触发webpack global var 注入
|
|
260
|
+
let output = 'global.currentModuleId;\n'
|
|
261
|
+
|
|
200
262
|
for (let type in typeResourceMap) {
|
|
201
|
-
output += `/* ${type} */\n${
|
|
263
|
+
output += `/* ${type} */\n${getRequire(type)}\n\n`
|
|
202
264
|
}
|
|
203
265
|
|
|
204
266
|
callback(null, output)
|
package/lib/parser.js
CHANGED
|
@@ -6,7 +6,7 @@ const SourceMapGenerator = require('source-map').SourceMapGenerator
|
|
|
6
6
|
const splitRE = /\r?\n/g
|
|
7
7
|
const emptyRE = /^(?:\/\/)?\s*$/
|
|
8
8
|
|
|
9
|
-
module.exports = (content, { filePath, needMap, mode, env }) => {
|
|
9
|
+
module.exports = (content, { filePath, needMap, mode, defs, env }) => {
|
|
10
10
|
// 缓存需要mode隔离,不同mode经过区块条件编译parseComponent得到的内容并不一致
|
|
11
11
|
const cacheKey = hash(filePath + content + mode + env)
|
|
12
12
|
|
|
@@ -14,6 +14,7 @@ module.exports = (content, { filePath, needMap, mode, env }) => {
|
|
|
14
14
|
if (output) return JSON.parse(output)
|
|
15
15
|
output = compiler.parseComponent(content, {
|
|
16
16
|
mode,
|
|
17
|
+
defs,
|
|
17
18
|
filePath,
|
|
18
19
|
pad: 'line',
|
|
19
20
|
env
|
|
@@ -246,7 +246,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
246
246
|
jd: deletePath()
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
|
-
test: 'navigateToMiniProgramAppIdList|networkTimeout',
|
|
249
|
+
test: 'navigateToMiniProgramAppIdList|networkTimeout|permission',
|
|
250
250
|
ali: deletePath(),
|
|
251
251
|
jd: deletePath()
|
|
252
252
|
},
|
|
@@ -4,7 +4,7 @@ const runRules = require('../run-rules')
|
|
|
4
4
|
* @desc 针对每一个组件(属性,event,指令等)执行规则判断
|
|
5
5
|
* @params cfgs [{test: 'camera', props:[], event: []}] 组件配置列表
|
|
6
6
|
* @params spec ../index.js中公共的spec
|
|
7
|
-
|
|
7
|
+
*/
|
|
8
8
|
module.exports = function normalizeComponentRules (cfgs, spec) {
|
|
9
9
|
return cfgs.map((cfg) => {
|
|
10
10
|
const result = {}
|
|
@@ -25,8 +25,9 @@ module.exports = function normalizeComponentRules (cfgs, spec) {
|
|
|
25
25
|
data
|
|
26
26
|
}
|
|
27
27
|
el.attrsList.forEach((attr) => {
|
|
28
|
+
let rAttr = runRules(spec.preAttrs, attr, options)
|
|
28
29
|
const meta = {}
|
|
29
|
-
|
|
30
|
+
rAttr = runRules(spec.directive, rAttr, {
|
|
30
31
|
...options,
|
|
31
32
|
meta
|
|
32
33
|
})
|
|
@@ -28,8 +28,6 @@ module.exports = function ({ print }) {
|
|
|
28
28
|
const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
|
|
29
29
|
const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })
|
|
30
30
|
const webEventLog = print({ platform: 'web', tag: TAG_NAME, isError: false, type: 'event' })
|
|
31
|
-
const tenonPropLog = print({ platform: 'tenon', tag: TAG_NAME, isError: false })
|
|
32
|
-
const tenonEventLog = print({ platform: 'tenon', tag: TAG_NAME, isError: false, type: 'event' })
|
|
33
31
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
34
32
|
const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
|
|
35
33
|
|
|
@@ -39,10 +37,6 @@ module.exports = function ({ print }) {
|
|
|
39
37
|
el.isBuiltIn = true
|
|
40
38
|
return 'mpx-button'
|
|
41
39
|
},
|
|
42
|
-
tenon (tag, { el }) {
|
|
43
|
-
el.isBuiltIn = true
|
|
44
|
-
return 'tenon-button'
|
|
45
|
-
},
|
|
46
40
|
props: [
|
|
47
41
|
{
|
|
48
42
|
test: 'open-type',
|
|
@@ -137,18 +131,13 @@ module.exports = function ({ print }) {
|
|
|
137
131
|
},
|
|
138
132
|
{
|
|
139
133
|
test: /^(open-type|lang|session-from|send-message-title|send-message-path|send-message-img|show-message-card|app-parameter)$/,
|
|
140
|
-
web: webPropLog
|
|
141
|
-
tenon: tenonPropLog
|
|
134
|
+
web: webPropLog
|
|
142
135
|
},
|
|
143
136
|
{
|
|
144
137
|
test: /^(size|type|plain|loading|form-type|hover-class|hover-stop-propagation|hover-start-time|hover-stay-time|use-built-in)$/,
|
|
145
138
|
web (prop, { el }) {
|
|
146
139
|
// todo 这部分能力基于内部封装实现
|
|
147
140
|
el.isBuiltIn = true
|
|
148
|
-
},
|
|
149
|
-
tenon (prop, { el }) {
|
|
150
|
-
// todo 这部分能力基于内部封装实现
|
|
151
|
-
el.isBuiltIn = true
|
|
152
141
|
}
|
|
153
142
|
},
|
|
154
143
|
{
|
|
@@ -185,8 +174,7 @@ module.exports = function ({ print }) {
|
|
|
185
174
|
},
|
|
186
175
|
{
|
|
187
176
|
test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
|
|
188
|
-
web: webEventLog
|
|
189
|
-
tenon: tenonEventLog
|
|
177
|
+
web: webEventLog
|
|
190
178
|
}
|
|
191
179
|
]
|
|
192
180
|
}
|
|
@@ -20,10 +20,6 @@ module.exports = function ({ print }) {
|
|
|
20
20
|
el.isBuiltIn = true
|
|
21
21
|
return 'mpx-input'
|
|
22
22
|
},
|
|
23
|
-
tenon (tag, { el }) {
|
|
24
|
-
el.isBuiltIn = true
|
|
25
|
-
return 'tenon-input'
|
|
26
|
-
},
|
|
27
23
|
props: [
|
|
28
24
|
{
|
|
29
25
|
test: /^(cursor-spacing|auto-focus|adjust-position|hold-keyboard)$/,
|
|
@@ -19,10 +19,6 @@ module.exports = function ({ print }) {
|
|
|
19
19
|
el.isBuiltIn = true
|
|
20
20
|
return 'mpx-scroll-view'
|
|
21
21
|
},
|
|
22
|
-
tenon (tag, { el }) {
|
|
23
|
-
el.isBuiltIn = true
|
|
24
|
-
return 'tenon-scroll-view'
|
|
25
|
-
},
|
|
26
22
|
props: [
|
|
27
23
|
{
|
|
28
24
|
test: /^(enable-flex|scroll-anchorin|refresher-enabled|refresher-threshold|refresher-default-style|refresher-background|refresher-triggered|enhanced|bounces|show-scrollbar|paging-enabled|fast-deceleratio)$/,
|
|
@@ -22,11 +22,6 @@ module.exports = function ({ print }) {
|
|
|
22
22
|
el.isBuiltIn = true
|
|
23
23
|
return 'mpx-textarea'
|
|
24
24
|
},
|
|
25
|
-
tenon (tag, { el }) {
|
|
26
|
-
// form全量使用内建组件
|
|
27
|
-
el.isBuiltIn = true
|
|
28
|
-
return 'tenon-textarea'
|
|
29
|
-
},
|
|
30
25
|
props: [
|
|
31
26
|
{
|
|
32
27
|
test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
|