@mpxjs/webpack-plugin 2.6.115 → 2.7.0-alpha
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/AppEntryDependency.js +58 -0
- package/lib/dependencies/CommonJsAsyncDependency.js +51 -0
- package/lib/dependencies/CommonJsVariableDependency.js +81 -0
- package/lib/dependencies/DynamicEntryDependency.js +171 -0
- package/lib/dependencies/FlagPluginDependency.js +24 -0
- package/lib/dependencies/InjectDependency.js +43 -0
- package/lib/dependencies/RecordGlobalComponentsDependency.js +50 -0
- package/lib/dependencies/RecordIndependentDependency.js +44 -0
- package/lib/dependencies/RecordResourceMapDependency.js +62 -0
- package/lib/dependencies/RemoveEntryDependency.js +40 -0
- package/lib/{dependency → dependencies}/ReplaceDependency.js +19 -2
- package/lib/dependencies/ResolveDependency.js +88 -0
- package/lib/extractor.js +82 -178
- package/lib/file-loader.js +7 -19
- package/lib/helpers.js +39 -334
- package/lib/independent-loader.js +52 -0
- package/lib/index.js +889 -525
- package/lib/json-compiler/helper.js +156 -0
- package/lib/json-compiler/index.js +245 -451
- package/lib/json-compiler/plugin.js +150 -0
- package/lib/json-compiler/{theme-loader.js → theme.js} +5 -3
- package/lib/loader.js +178 -241
- package/lib/native-loader.js +71 -133
- package/lib/parser.js +1 -2
- package/lib/partial-compile/index.js +35 -0
- package/lib/platform/json/wx/index.js +1 -1
- package/lib/platform/template/normalize-component-rules.js +2 -3
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +4 -0
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +5 -0
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +149 -3
- package/lib/record-loader.js +11 -0
- package/lib/resolve-loader.js +6 -0
- package/lib/resolver/AddEnvPlugin.js +4 -3
- package/lib/resolver/AddModePlugin.js +4 -3
- package/lib/resolver/FixDescriptionInfoPlugin.js +28 -0
- package/lib/resolver/PackageEntryPlugin.js +23 -36
- package/lib/runtime/base.styl +5 -0
- package/lib/runtime/components/tenon/getInnerListeners.js +317 -0
- package/lib/runtime/components/tenon/tenon-button.vue +305 -0
- package/lib/runtime/components/tenon/tenon-image.vue +61 -0
- package/lib/runtime/components/tenon/tenon-input.vue +99 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +21 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +124 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
- package/lib/runtime/components/tenon/tenon-text-area.vue +64 -0
- package/lib/runtime/components/tenon/tenon-text.vue +64 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- package/lib/runtime/components/tenon/util.js +44 -0
- package/lib/runtime/components/web/getInnerListeners.js +1 -3
- package/lib/runtime/components/web/mpx-image.vue +20 -5
- package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
- package/lib/runtime/components/web/mpx-swiper.vue +18 -3
- package/lib/runtime/i18n.wxs +31 -11
- package/lib/runtime/optionProcessor.js +48 -3
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/selector.js +29 -10
- package/lib/style-compiler/index.js +16 -24
- package/lib/style-compiler/load-postcss-config.js +3 -1
- package/lib/style-compiler/plugins/conditional-strip.js +68 -65
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/style-compiler/plugins/rpx.js +43 -37
- package/lib/style-compiler/plugins/scope-id.js +79 -72
- package/lib/style-compiler/plugins/trans-special.js +25 -18
- package/lib/style-compiler/plugins/trim.js +13 -7
- package/lib/style-compiler/plugins/vw.js +22 -16
- package/lib/template-compiler/compiler.js +106 -199
- package/lib/template-compiler/index.js +52 -139
- package/lib/template-compiler/trans-dynamic-class-expr.js +18 -13
- package/lib/tenon/index.js +105 -0
- package/lib/tenon/processJSON.js +356 -0
- package/lib/tenon/processScript.js +261 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/url-loader.js +11 -29
- package/lib/utils/add-query.js +1 -1
- package/lib/utils/const.js +10 -0
- package/lib/utils/emit-file.js +10 -0
- package/lib/utils/eval-json-js.js +31 -0
- package/lib/utils/get-entry-name.js +13 -0
- package/lib/utils/get-json-content.js +42 -0
- package/lib/utils/get-relative-path.js +25 -0
- package/lib/utils/is-url-request.js +10 -1
- package/lib/utils/match-condition.js +4 -1
- package/lib/utils/normalize.js +4 -15
- package/lib/utils/parse-request.js +3 -3
- package/lib/utils/resolve.js +13 -0
- package/lib/utils/set.js +47 -0
- package/lib/utils/stringify-loaders-resource.js +25 -0
- package/lib/utils/stringify-query.js +4 -0
- package/lib/web/processJSON.js +113 -144
- package/lib/web/processScript.js +47 -34
- package/lib/web/processTemplate.js +57 -40
- package/lib/wxml/{wxml-loader.js → loader.js} +21 -62
- package/lib/wxs/WxsModuleIdsPlugin.js +29 -0
- package/lib/wxs/WxsParserPlugin.js +2 -2
- package/lib/wxs/WxsPlugin.js +4 -8
- package/lib/wxs/WxsTemplatePlugin.js +46 -92
- package/lib/wxs/{wxs-i18n-loader.js → i18n-loader.js} +5 -4
- package/lib/wxs/loader.js +142 -0
- package/lib/wxs/{wxs-pre-loader.js → pre-loader.js} +20 -5
- package/lib/wxss/loader.js +31 -43
- package/lib/wxss/localsLoader.js +1 -5
- package/lib/wxss/processCss.js +107 -103
- package/package.json +21 -18
- package/lib/built-in-loader.js +0 -49
- package/lib/content-loader.js +0 -13
- package/lib/dependency/ChildCompileDependency.js +0 -24
- package/lib/dependency/InjectDependency.js +0 -26
- package/lib/dependency/RemovedModuleDependency.js +0 -23
- package/lib/dependency/ResolveDependency.js +0 -49
- package/lib/path-loader.js +0 -3
- package/lib/plugin-loader.js +0 -287
- package/lib/staticConfig.js +0 -4
- package/lib/utils/get-main-compilation.js +0 -6
- package/lib/utils/read-json-for-src.js +0 -34
- package/lib/utils/try-require.js +0 -16
- package/lib/wxs/wxs-loader.js +0 -117
- package/lib/wxss/getImportPrefix.js +0 -30
package/lib/native-loader.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
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')
|
|
5
4
|
const config = require('./config')
|
|
6
5
|
const createHelpers = require('./helpers')
|
|
7
|
-
const
|
|
8
|
-
const addQuery = require('./utils/add-query')
|
|
9
|
-
const mpxJSON = require('./utils/mpx-json')
|
|
6
|
+
const getJSONContent = require('./utils/get-json-content')
|
|
10
7
|
const async = require('async')
|
|
11
|
-
const matchCondition = require('./utils/match-condition')
|
|
8
|
+
const { matchCondition } = require('./utils/match-condition')
|
|
12
9
|
const fixUsingComponent = require('./utils/fix-using-component')
|
|
13
|
-
const
|
|
10
|
+
const { JSON_JS_EXT } = require('./utils/const')
|
|
14
11
|
|
|
15
12
|
module.exports = function (content) {
|
|
16
13
|
this.cacheable()
|
|
17
14
|
|
|
18
|
-
const
|
|
19
|
-
const mpx = mainCompilation.__mpx__
|
|
15
|
+
const mpx = this.getMpx()
|
|
20
16
|
if (!mpx) {
|
|
21
17
|
return content
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
const nativeCallback = this.async()
|
|
25
|
-
|
|
26
21
|
const loaderContext = this
|
|
27
22
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
28
|
-
const options = Object.assign({}, mpx.loaderOptions, loaderUtils.getOptions(this))
|
|
29
|
-
|
|
30
23
|
const filePath = this.resourcePath
|
|
31
|
-
|
|
32
24
|
const moduleId = 'm' + mpx.pathHash(filePath)
|
|
33
25
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
34
|
-
const projectRoot = mpx.projectRoot
|
|
35
26
|
const mode = mpx.mode
|
|
36
|
-
const defs = mpx.defs
|
|
37
27
|
const globalSrcMode = mpx.srcMode
|
|
38
28
|
const localSrcMode = queryObj.mode
|
|
39
29
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
@@ -41,14 +31,12 @@ module.exports = function (content) {
|
|
|
41
31
|
const componentsMap = mpx.componentsMap[packageName]
|
|
42
32
|
const parsed = path.parse(resourcePath)
|
|
43
33
|
const resourceName = path.join(parsed.dir, parsed.name)
|
|
44
|
-
const isApp = !pagesMap[resourcePath]
|
|
34
|
+
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
45
35
|
const srcMode = localSrcMode || globalSrcMode
|
|
46
|
-
const fs = this._compiler.inputFileSystem
|
|
47
36
|
const typeExtMap = config[srcMode].typeExtMap
|
|
48
37
|
const typeResourceMap = {}
|
|
49
38
|
const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
|
|
50
39
|
|
|
51
|
-
const EXT_MPX_JSON = '.json.js'
|
|
52
40
|
const CSS_LANG_EXT_MAP = {
|
|
53
41
|
less: '.less',
|
|
54
42
|
stylus: '.styl',
|
|
@@ -56,40 +44,18 @@ module.exports = function (content) {
|
|
|
56
44
|
scss: '.scss'
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
let
|
|
47
|
+
let useJSONJS = false
|
|
60
48
|
let cssLang = ''
|
|
61
49
|
const hasScoped = (queryObj.scoped || autoScope) && mode === 'ali'
|
|
62
50
|
const hasComment = false
|
|
63
51
|
const isNative = true
|
|
64
52
|
|
|
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
|
-
|
|
84
53
|
const checkFileExists = (extName, callback) => {
|
|
85
|
-
this.resolve(parsed.dir, resourceName + extName,
|
|
86
|
-
err = null
|
|
87
|
-
callback(err, result)
|
|
88
|
-
})
|
|
54
|
+
this.resolve(parsed.dir, resourceName + extName, callback)
|
|
89
55
|
}
|
|
90
56
|
|
|
91
57
|
function checkCSSLangFiles (callback) {
|
|
92
|
-
const langs = mpx.
|
|
58
|
+
const langs = mpx.nativeConfig.cssLangs || ['less', 'stylus', 'scss', 'sass']
|
|
93
59
|
const results = []
|
|
94
60
|
async.eachOf(langs, function (lang, i, callback) {
|
|
95
61
|
if (!CSS_LANG_EXT_MAP[lang]) {
|
|
@@ -99,7 +65,7 @@ module.exports = function (content) {
|
|
|
99
65
|
if (!err && result) {
|
|
100
66
|
results[i] = result
|
|
101
67
|
}
|
|
102
|
-
callback(
|
|
68
|
+
callback()
|
|
103
69
|
})
|
|
104
70
|
}, function (err) {
|
|
105
71
|
for (let i = 0; i < langs.length; i++) {
|
|
@@ -113,14 +79,13 @@ module.exports = function (content) {
|
|
|
113
79
|
})
|
|
114
80
|
}
|
|
115
81
|
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
checkFileExists(EXT_MPX_JSON, (err, result) => {
|
|
82
|
+
function checkJSONJSFile (callback) {
|
|
83
|
+
checkFileExists(JSON_JS_EXT, (err, result) => {
|
|
119
84
|
if (!err && result) {
|
|
120
85
|
typeResourceMap.json = result
|
|
121
|
-
|
|
86
|
+
useJSONJS = true
|
|
122
87
|
}
|
|
123
|
-
callback(
|
|
88
|
+
callback()
|
|
124
89
|
})
|
|
125
90
|
}
|
|
126
91
|
|
|
@@ -129,138 +94,111 @@ module.exports = function (content) {
|
|
|
129
94
|
(callback) => {
|
|
130
95
|
async.parallel([
|
|
131
96
|
checkCSSLangFiles,
|
|
132
|
-
|
|
97
|
+
checkJSONJSFile
|
|
133
98
|
], (err) => {
|
|
134
99
|
callback(err)
|
|
135
100
|
})
|
|
136
101
|
},
|
|
137
102
|
(callback) => {
|
|
138
103
|
async.forEachOf(typeExtMap, (ext, key, callback) => {
|
|
139
|
-
// 检测到
|
|
140
|
-
if (
|
|
104
|
+
// 检测到jsonjs或cssLang时跳过对应类型文件检测
|
|
105
|
+
if (typeResourceMap[key]) {
|
|
141
106
|
return callback()
|
|
142
107
|
}
|
|
143
108
|
checkFileExists(ext, (err, result) => {
|
|
144
109
|
if (!err && result) {
|
|
145
110
|
typeResourceMap[key] = result
|
|
146
111
|
}
|
|
147
|
-
callback(
|
|
112
|
+
callback()
|
|
148
113
|
})
|
|
149
114
|
}, callback)
|
|
150
115
|
},
|
|
151
116
|
(callback) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
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
|
-
}
|
|
117
|
+
getJSONContent({
|
|
118
|
+
src: typeResourceMap.json,
|
|
119
|
+
useJSONJS
|
|
120
|
+
}, this, callback)
|
|
170
121
|
}, (content, callback) => {
|
|
171
|
-
let
|
|
122
|
+
let json
|
|
172
123
|
try {
|
|
173
|
-
|
|
174
|
-
if (ret.usingComponents) {
|
|
175
|
-
fixUsingComponent(ret.usingComponents, mode)
|
|
176
|
-
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
177
|
-
}
|
|
124
|
+
json = JSON5.parse(content)
|
|
178
125
|
} 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))
|
|
179
132
|
}
|
|
180
133
|
const {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
134
|
+
getRequire
|
|
135
|
+
} = createHelpers(loaderContext)
|
|
136
|
+
|
|
137
|
+
const getRequireByType = (type) => {
|
|
138
|
+
const src = typeResourceMap[type]
|
|
139
|
+
const part = { src }
|
|
140
|
+
const extraOptions = {
|
|
141
|
+
...queryObj,
|
|
142
|
+
resourcePath
|
|
207
143
|
}
|
|
208
|
-
src = addQuery(src, localQuery, true)
|
|
209
|
-
const partsOpts = { src }
|
|
210
144
|
|
|
211
|
-
|
|
212
|
-
|
|
145
|
+
switch (type) {
|
|
146
|
+
case 'template':
|
|
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
|
|
213
166
|
}
|
|
214
|
-
|
|
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)
|
|
167
|
+
return getRequire(type, part, extraOptions)
|
|
223
168
|
}
|
|
224
169
|
|
|
225
170
|
// 注入模块id及资源路径
|
|
226
|
-
let
|
|
171
|
+
let output = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
227
172
|
if (!isProduction) {
|
|
228
|
-
|
|
173
|
+
output += `global.currentResource = ${JSON.stringify(filePath)}\n`
|
|
229
174
|
}
|
|
230
175
|
|
|
231
176
|
// 注入构造函数
|
|
232
177
|
let ctor = 'App'
|
|
178
|
+
let ctorType = 'app'
|
|
233
179
|
if (pagesMap[resourcePath]) {
|
|
234
|
-
|
|
180
|
+
ctorType = 'page'
|
|
181
|
+
if (mpx.forceUsePageCtor || mode === 'ali' || mode === 'swan') {
|
|
235
182
|
ctor = 'Page'
|
|
236
183
|
} else {
|
|
237
184
|
ctor = 'Component'
|
|
238
185
|
}
|
|
239
186
|
} else if (componentsMap[resourcePath]) {
|
|
240
187
|
ctor = 'Component'
|
|
188
|
+
ctorType = 'component'
|
|
241
189
|
}
|
|
242
|
-
|
|
243
|
-
|
|
190
|
+
output += `global.currentCtor = ${ctor}\n`
|
|
191
|
+
output += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
|
|
244
192
|
return match.toLowerCase()
|
|
245
193
|
}))}\n`
|
|
194
|
+
output += `global.currentResourceType = ${JSON.stringify(ctorType)}\n`
|
|
246
195
|
|
|
247
196
|
if (srcMode) {
|
|
248
|
-
|
|
197
|
+
output += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
|
|
249
198
|
}
|
|
250
199
|
|
|
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
|
-
|
|
262
200
|
for (let type in typeResourceMap) {
|
|
263
|
-
output += `/* ${type} */\n${
|
|
201
|
+
output += `/* ${type} */\n${getRequireByType(type)}\n\n`
|
|
264
202
|
}
|
|
265
203
|
|
|
266
204
|
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,
|
|
9
|
+
module.exports = (content, { filePath, needMap, mode, env }) => {
|
|
10
10
|
// 缓存需要mode隔离,不同mode经过区块条件编译parseComponent得到的内容并不一致
|
|
11
11
|
const cacheKey = hash(filePath + content + mode + env)
|
|
12
12
|
|
|
@@ -14,7 +14,6 @@ module.exports = (content, { filePath, needMap, mode, defs, env }) => {
|
|
|
14
14
|
if (output) return JSON.parse(output)
|
|
15
15
|
output = compiler.parseComponent(content, {
|
|
16
16
|
mode,
|
|
17
|
-
defs,
|
|
18
17
|
filePath,
|
|
19
18
|
pad: 'line',
|
|
20
19
|
env
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { matchCondition } = require('../utils/match-condition')
|
|
2
|
+
const { parseQuery } = require('loader-utils')
|
|
3
|
+
|
|
4
|
+
class MpxPartialCompilePlugin {
|
|
5
|
+
constructor (condition) {
|
|
6
|
+
this.condition = condition
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
isResolvingPage (obj) {
|
|
10
|
+
// valid query should start with '?'
|
|
11
|
+
const query = obj.query || '?'
|
|
12
|
+
return parseQuery(query).isPage
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
apply (compiler) {
|
|
16
|
+
compiler.resolverFactory.hooks.resolver.intercept({
|
|
17
|
+
factory: (type, hook) => {
|
|
18
|
+
hook.tap('MpxPartialCompilePlugin', (resolver) => {
|
|
19
|
+
resolver.hooks.result.tapAsync({
|
|
20
|
+
name: 'MpxPartialCompilePlugin',
|
|
21
|
+
stage: -100
|
|
22
|
+
}, (obj, resolverContext, callback) => {
|
|
23
|
+
if (this.isResolvingPage(obj) && !matchCondition(obj.path, this.condition)) {
|
|
24
|
+
obj.path = false
|
|
25
|
+
}
|
|
26
|
+
callback(null, obj)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
return hook
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = MpxPartialCompilePlugin
|
|
@@ -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',
|
|
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,9 +25,8 @@ 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)
|
|
29
28
|
const meta = {}
|
|
30
|
-
rAttr = runRules(spec.directive,
|
|
29
|
+
let rAttr = runRules(spec.directive, attr, {
|
|
31
30
|
...options,
|
|
32
31
|
meta
|
|
33
32
|
})
|
|
@@ -28,6 +28,8 @@ 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' })
|
|
31
33
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
32
34
|
const wxPropValueLog = print({ platform: 'wx', tag: TAG_NAME, isError: false, type: 'value' })
|
|
33
35
|
|
|
@@ -37,6 +39,10 @@ module.exports = function ({ print }) {
|
|
|
37
39
|
el.isBuiltIn = true
|
|
38
40
|
return 'mpx-button'
|
|
39
41
|
},
|
|
42
|
+
tenon (tag, { el }) {
|
|
43
|
+
el.isBuiltIn = true
|
|
44
|
+
return 'tenon-button'
|
|
45
|
+
},
|
|
40
46
|
props: [
|
|
41
47
|
{
|
|
42
48
|
test: 'open-type',
|
|
@@ -131,13 +137,18 @@ module.exports = function ({ print }) {
|
|
|
131
137
|
},
|
|
132
138
|
{
|
|
133
139
|
test: /^(open-type|lang|session-from|send-message-title|send-message-path|send-message-img|show-message-card|app-parameter)$/,
|
|
134
|
-
web: webPropLog
|
|
140
|
+
web: webPropLog,
|
|
141
|
+
tenon: tenonPropLog
|
|
135
142
|
},
|
|
136
143
|
{
|
|
137
144
|
test: /^(size|type|plain|loading|form-type|hover-class|hover-stop-propagation|hover-start-time|hover-stay-time|use-built-in)$/,
|
|
138
145
|
web (prop, { el }) {
|
|
139
146
|
// todo 这部分能力基于内部封装实现
|
|
140
147
|
el.isBuiltIn = true
|
|
148
|
+
},
|
|
149
|
+
tenon (prop, { el }) {
|
|
150
|
+
// todo 这部分能力基于内部封装实现
|
|
151
|
+
el.isBuiltIn = true
|
|
141
152
|
}
|
|
142
153
|
},
|
|
143
154
|
{
|
|
@@ -174,7 +185,8 @@ module.exports = function ({ print }) {
|
|
|
174
185
|
},
|
|
175
186
|
{
|
|
176
187
|
test: /^(getuserinfo|contact|error|launchapp|opensetting|getphonenumber)$/,
|
|
177
|
-
web: webEventLog
|
|
188
|
+
web: webEventLog,
|
|
189
|
+
tenon: tenonEventLog
|
|
178
190
|
}
|
|
179
191
|
]
|
|
180
192
|
}
|
|
@@ -20,6 +20,10 @@ 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
|
+
},
|
|
23
27
|
props: [
|
|
24
28
|
{
|
|
25
29
|
test: /^(cursor-spacing|auto-focus|adjust-position|hold-keyboard)$/,
|
|
@@ -19,6 +19,10 @@ 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
|
+
},
|
|
22
26
|
props: [
|
|
23
27
|
{
|
|
24
28
|
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,6 +22,11 @@ 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
|
+
},
|
|
25
30
|
props: [
|
|
26
31
|
{
|
|
27
32
|
test: /^(auto-focus|fixed|cursor-spacing|cursor|show-confirm-bar|selection-start|selection-end|adjust-position|hold-keyboard|disable-default-padding|confirm-type)$/,
|