@mpxjs/webpack-plugin 2.6.113 → 2.6.114-alpha.2
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/config.js +14 -0
- package/lib/dependency/AddEntryDependency.js +24 -0
- package/lib/dependency/ResolveDependency.js +4 -0
- package/lib/index.js +44 -3
- package/lib/json-compiler/index.js +3 -0
- package/lib/loader.js +43 -2
- package/lib/path-loader.js +4 -1
- 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 +117 -1
- package/lib/runtime/components/tenon/getInnerListeners.js +308 -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/optionProcessor.tenon.js +386 -0
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/compiler.js +11 -2
- package/lib/template-compiler/trans-dynamic-class-expr.js +1 -1
- package/lib/tenon/index.js +108 -0
- package/lib/tenon/processJSON.js +361 -0
- package/lib/tenon/processScript.js +260 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/utils/get-relative-path.js +24 -0
- package/package.json +7 -3
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// import { inBrowser } from '../utils/env'
|
|
2
|
+
|
|
3
|
+
export default function processOption (
|
|
4
|
+
option,
|
|
5
|
+
ctorType,
|
|
6
|
+
firstPage,
|
|
7
|
+
componentId,
|
|
8
|
+
pageConfig,
|
|
9
|
+
pagesMap,
|
|
10
|
+
componentsMap,
|
|
11
|
+
tabBarMap,
|
|
12
|
+
componentGenerics,
|
|
13
|
+
genericsInfo,
|
|
14
|
+
mixin,
|
|
15
|
+
Vue,
|
|
16
|
+
VueRouter,
|
|
17
|
+
i18n
|
|
18
|
+
) {
|
|
19
|
+
if (ctorType === 'app') {
|
|
20
|
+
// 对于app中的组件需要全局注册
|
|
21
|
+
for (const componentName in componentsMap) {
|
|
22
|
+
if (componentsMap.hasOwnProperty(componentName)) {
|
|
23
|
+
const component = componentsMap[componentName]
|
|
24
|
+
Vue.component(componentName, component)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 注册v-ex-classes自定义指令处理externalClasses
|
|
29
|
+
// Vue.directive('ex-classes', (el, binding, vnode) => {
|
|
30
|
+
// const context = vnode.context
|
|
31
|
+
// if (context) {
|
|
32
|
+
// const externalClasses = context.$options.externalClasses || []
|
|
33
|
+
// const classList = el.classList
|
|
34
|
+
// binding.value.forEach((className) => {
|
|
35
|
+
// const actualExternalClassNames = context.$attrs[className]
|
|
36
|
+
// if (externalClasses.indexOf(className) !== -1 && actualExternalClassNames) {
|
|
37
|
+
// classList.remove(className)
|
|
38
|
+
// actualExternalClassNames.split(/\s+/).forEach((actualExternalClassName) => {
|
|
39
|
+
// if (actualExternalClassName) classList.add(actualExternalClassName)
|
|
40
|
+
// })
|
|
41
|
+
// }
|
|
42
|
+
// })
|
|
43
|
+
// }
|
|
44
|
+
// })
|
|
45
|
+
// Vue.directive('animation', (el, binding) => {
|
|
46
|
+
// const newActions = binding?.value?.actions
|
|
47
|
+
// if (el.actions === newActions) {
|
|
48
|
+
// Promise.resolve().then(() => {
|
|
49
|
+
// Object.assign(el.style, el.lastDynamicStyle)
|
|
50
|
+
// })
|
|
51
|
+
// return
|
|
52
|
+
// }
|
|
53
|
+
// el.actions = newActions
|
|
54
|
+
// if (typeof el.setAnimation === 'function') {
|
|
55
|
+
// el.removeEventListener('transitionend', el.setAnimation, false)
|
|
56
|
+
// el.setAnimation = undefined
|
|
57
|
+
// }
|
|
58
|
+
// el.dynamicStyleQueue = []
|
|
59
|
+
// el.lastDynamicStyle = undefined
|
|
60
|
+
// if (Array.isArray(newActions) && newActions.length) {
|
|
61
|
+
// newActions.forEach((item) => {
|
|
62
|
+
// const property = []
|
|
63
|
+
// const { animates, option } = item
|
|
64
|
+
// // 存储动画需要改变的样式属性
|
|
65
|
+
// const dynamicStyle = {
|
|
66
|
+
// transform: ''
|
|
67
|
+
// }
|
|
68
|
+
// animates.forEach((itemAnimation) => {
|
|
69
|
+
// switch (itemAnimation.type) {
|
|
70
|
+
// case 'style':
|
|
71
|
+
// const [key, value] = itemAnimation.args
|
|
72
|
+
// dynamicStyle[key] = value
|
|
73
|
+
// property.push(key)
|
|
74
|
+
// break
|
|
75
|
+
// default:
|
|
76
|
+
// dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
77
|
+
// if (!property.includes('transform')) {
|
|
78
|
+
// property.push('transform')
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// })
|
|
82
|
+
// Object.assign(dynamicStyle, {
|
|
83
|
+
// transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
84
|
+
// transitionProperty: `${property}`,
|
|
85
|
+
// transformOrigin: option.transformOrigin
|
|
86
|
+
// })
|
|
87
|
+
// el.dynamicStyleQueue.push(dynamicStyle)
|
|
88
|
+
// })
|
|
89
|
+
// el.setAnimation = function () {
|
|
90
|
+
// if (!el.dynamicStyleQueue.length) {
|
|
91
|
+
// el.removeEventListener('transitionend', el.setAnimation, false)
|
|
92
|
+
// return
|
|
93
|
+
// }
|
|
94
|
+
// const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
95
|
+
// Object.assign(el.style, dynamicStyle)
|
|
96
|
+
// el.lastDynamicStyle = dynamicStyle
|
|
97
|
+
// }
|
|
98
|
+
// // 首次动画属性设置
|
|
99
|
+
// setTimeout(el.setAnimation, 0)
|
|
100
|
+
// // 在transitionend事件内设置动画样式
|
|
101
|
+
// el.addEventListener('transitionend', el.setAnimation, false)
|
|
102
|
+
// }
|
|
103
|
+
// })
|
|
104
|
+
|
|
105
|
+
// const routes = []
|
|
106
|
+
|
|
107
|
+
// for (const pagePath in pagesMap) {
|
|
108
|
+
// if (pagesMap.hasOwnProperty(pagePath)) {
|
|
109
|
+
// const page = pagesMap[pagePath]
|
|
110
|
+
// routes.push({
|
|
111
|
+
// path: '/' + pagePath,
|
|
112
|
+
// component: page
|
|
113
|
+
// })
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// if (routes.length) {
|
|
118
|
+
// if (firstPage) {
|
|
119
|
+
// routes.push({
|
|
120
|
+
// path: '/',
|
|
121
|
+
// redirect: '/' + firstPage
|
|
122
|
+
// })
|
|
123
|
+
// }
|
|
124
|
+
// global.__mpxRouter = option.router = new VueRouter({
|
|
125
|
+
// routes: routes
|
|
126
|
+
// })
|
|
127
|
+
// global.__mpxRouter.stack = []
|
|
128
|
+
// global.__mpxRouter.needCache = null
|
|
129
|
+
// global.__mpxRouter.needRemove = []
|
|
130
|
+
// // 处理reLaunch中传递的url并非首页时的replace逻辑
|
|
131
|
+
// global.__mpxRouter.beforeEach(function (to, from, next) {
|
|
132
|
+
// let action = global.__mpxRouter.__mpxAction
|
|
133
|
+
// const stack = global.__mpxRouter.stack
|
|
134
|
+
|
|
135
|
+
// // 处理人为操作
|
|
136
|
+
// if (!action) {
|
|
137
|
+
// if (stack.length > 1 && stack[stack.length - 2].path === to.path) {
|
|
138
|
+
// action = {
|
|
139
|
+
// type: 'back',
|
|
140
|
+
// delta: 1
|
|
141
|
+
// }
|
|
142
|
+
// } else {
|
|
143
|
+
// action = {
|
|
144
|
+
// type: 'to'
|
|
145
|
+
// }
|
|
146
|
+
// }
|
|
147
|
+
// }
|
|
148
|
+
|
|
149
|
+
// const pageInRoutes = routes.some(item => item.path === to.path)
|
|
150
|
+
// if (!pageInRoutes) {
|
|
151
|
+
// if (stack.length < 1) {
|
|
152
|
+
// if (global.__mpxRouter.app.$options.onPageNotFound) {
|
|
153
|
+
// // onPageNotFound,仅首次进入时生效
|
|
154
|
+
// global.__mpxRouter.app.$options.onPageNotFound({
|
|
155
|
+
// path: to.path,
|
|
156
|
+
// query: to.query,
|
|
157
|
+
// isEntryPage: true
|
|
158
|
+
// })
|
|
159
|
+
// return
|
|
160
|
+
// } else {
|
|
161
|
+
// console.warn(`[Mpx runtime warn]: the ${to.path} path does not exist in the application,will redirect to the home page path ${firstPage}`)
|
|
162
|
+
// return next({
|
|
163
|
+
// path: firstPage,
|
|
164
|
+
// replace: true
|
|
165
|
+
// })
|
|
166
|
+
// }
|
|
167
|
+
// } else {
|
|
168
|
+
// let methods = ''
|
|
169
|
+
// switch (action.type) {
|
|
170
|
+
// case 'to':
|
|
171
|
+
// methods = 'navigateTo'
|
|
172
|
+
// break
|
|
173
|
+
// case 'redirect':
|
|
174
|
+
// methods = 'redirectTo'
|
|
175
|
+
// break
|
|
176
|
+
// case 'back':
|
|
177
|
+
// methods = 'navigateBack'
|
|
178
|
+
// break
|
|
179
|
+
// case 'reLaunch':
|
|
180
|
+
// methods = 'reLaunch'
|
|
181
|
+
// break
|
|
182
|
+
// default:
|
|
183
|
+
// methods = 'navigateTo'
|
|
184
|
+
// }
|
|
185
|
+
// throw new Error(`${methods}:fail page "${to.path}" is not found`)
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
|
|
189
|
+
// const insertItem = {
|
|
190
|
+
// path: to.path
|
|
191
|
+
// }
|
|
192
|
+
// // 构建历史栈
|
|
193
|
+
// switch (action.type) {
|
|
194
|
+
// case 'to':
|
|
195
|
+
// stack.push(insertItem)
|
|
196
|
+
// global.__mpxRouter.needCache = insertItem
|
|
197
|
+
// break
|
|
198
|
+
// case 'back':
|
|
199
|
+
// global.__mpxRouter.needRemove = stack.splice(stack.length - action.delta, action.delta)
|
|
200
|
+
// break
|
|
201
|
+
// case 'redirect':
|
|
202
|
+
// global.__mpxRouter.needRemove = stack.splice(stack.length - 1, 1, insertItem)
|
|
203
|
+
// global.__mpxRouter.needCache = insertItem
|
|
204
|
+
// break
|
|
205
|
+
// case 'switch':
|
|
206
|
+
// if (!action.replaced) {
|
|
207
|
+
// action.replaced = true
|
|
208
|
+
// return next({
|
|
209
|
+
// path: action.path,
|
|
210
|
+
// replace: true
|
|
211
|
+
// })
|
|
212
|
+
// } else {
|
|
213
|
+
// // 将非tabBar页面remove
|
|
214
|
+
// let tabItem = null
|
|
215
|
+
// global.__mpxRouter.needRemove = stack.filter((item) => {
|
|
216
|
+
// if (tabBarMap[item.path.slice(1)]) {
|
|
217
|
+
// tabItem = item
|
|
218
|
+
// return false
|
|
219
|
+
// }
|
|
220
|
+
// return true
|
|
221
|
+
// })
|
|
222
|
+
// if (tabItem) {
|
|
223
|
+
// global.__mpxRouter.stack = [tabItem]
|
|
224
|
+
// } else {
|
|
225
|
+
// global.__mpxRouter.stack = [insertItem]
|
|
226
|
+
// global.__mpxRouter.needCache = insertItem
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
// break
|
|
230
|
+
// case 'reLaunch':
|
|
231
|
+
// if (!action.replaced) {
|
|
232
|
+
// action.replaced = true
|
|
233
|
+
// return next({
|
|
234
|
+
// path: action.path,
|
|
235
|
+
// query: {
|
|
236
|
+
// reLaunchCount: action.reLaunchCount
|
|
237
|
+
// },
|
|
238
|
+
// replace: true
|
|
239
|
+
// })
|
|
240
|
+
// } else {
|
|
241
|
+
// global.__mpxRouter.needRemove = stack
|
|
242
|
+
// global.__mpxRouter.stack = [insertItem]
|
|
243
|
+
// global.__mpxRouter.needCache = insertItem
|
|
244
|
+
// }
|
|
245
|
+
// }
|
|
246
|
+
// next()
|
|
247
|
+
// })
|
|
248
|
+
// // 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
249
|
+
// if (inBrowser) {
|
|
250
|
+
// // const errorHandler = function (e) {
|
|
251
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.error) {
|
|
252
|
+
// // global.__mpxAppCbs.error.forEach((cb) => {
|
|
253
|
+
// // cb(e)
|
|
254
|
+
// // })
|
|
255
|
+
// // }
|
|
256
|
+
// // }
|
|
257
|
+
// // Vue.config.errorHandler = errorHandler
|
|
258
|
+
// // window.addEventListener('error', errorHandler)
|
|
259
|
+
// // window.addEventListener('unhandledrejection', event => {
|
|
260
|
+
// // errorHandler(event.reason)
|
|
261
|
+
// // })
|
|
262
|
+
// // document.addEventListener('visibilitychange', function () {
|
|
263
|
+
// // const vnode = global.__mpxRouter && global.__mpxRouter.__mpxActiveVnode
|
|
264
|
+
// // if (vnode && vnode.componentInstance) {
|
|
265
|
+
// // const currentPage = vnode.tag.endsWith('mpx-tab-bar-container') ? vnode.componentInstance.$refs.tabBarPage : vnode.componentInstance
|
|
266
|
+
// // if (document.hidden) {
|
|
267
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.hide) {
|
|
268
|
+
// // global.__mpxAppCbs.hide.forEach((cb) => {
|
|
269
|
+
// // cb()
|
|
270
|
+
// // })
|
|
271
|
+
// // }
|
|
272
|
+
// // if (currentPage) {
|
|
273
|
+
// // currentPage.mpxPageStatus = 'hide'
|
|
274
|
+
// // currentPage.onHide && currentPage.onHide()
|
|
275
|
+
// // }
|
|
276
|
+
// // } else {
|
|
277
|
+
// // if (global.__mpxAppCbs && global.__mpxAppCbs.show) {
|
|
278
|
+
// // global.__mpxAppCbs.show.forEach((cb) => {
|
|
279
|
+
// // // todo 实现app.onShow参数
|
|
280
|
+
// // /* eslint-disable standard/no-callback-literal */
|
|
281
|
+
// // cb({})
|
|
282
|
+
// // })
|
|
283
|
+
// // }
|
|
284
|
+
// // if (currentPage) {
|
|
285
|
+
// // currentPage.mpxPageStatus = 'show'
|
|
286
|
+
// // currentPage.onShow && currentPage.onShow()
|
|
287
|
+
// // }
|
|
288
|
+
// // }
|
|
289
|
+
// // }
|
|
290
|
+
// // })
|
|
291
|
+
// // 初始化length
|
|
292
|
+
// // global.__mpxRouter.__mpxHistoryLength = global.history.length
|
|
293
|
+
// }
|
|
294
|
+
// }
|
|
295
|
+
|
|
296
|
+
// if (i18n) {
|
|
297
|
+
// option.i18n = i18n
|
|
298
|
+
// }
|
|
299
|
+
} else {
|
|
300
|
+
// 局部注册页面和组件中依赖的组件
|
|
301
|
+
for (const componentName in componentsMap) {
|
|
302
|
+
if (componentsMap.hasOwnProperty(componentName)) {
|
|
303
|
+
const component = componentsMap[componentName]
|
|
304
|
+
if (!option.components) {
|
|
305
|
+
option.components = {}
|
|
306
|
+
}
|
|
307
|
+
option.components[componentName] = component
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// if (genericsInfo) {
|
|
312
|
+
// const genericHash = genericsInfo.hash
|
|
313
|
+
// global.__mpxGenericsMap[genericHash] = {}
|
|
314
|
+
// Object.keys(genericsInfo.map).forEach((genericValue) => {
|
|
315
|
+
// if (componentsMap[genericValue]) {
|
|
316
|
+
// global.__mpxGenericsMap[genericHash][genericValue] = componentsMap[genericValue]
|
|
317
|
+
// } else {
|
|
318
|
+
// console.log(option)
|
|
319
|
+
// console.warn(`[Mpx runtime warn]: generic value "${genericValue}" must be
|
|
320
|
+
// registered in parent context!`)
|
|
321
|
+
// }
|
|
322
|
+
// })
|
|
323
|
+
// }
|
|
324
|
+
|
|
325
|
+
// if (componentGenerics) {
|
|
326
|
+
// option.props = option.props || {}
|
|
327
|
+
// option.props.generichash = String
|
|
328
|
+
// Object.keys(componentGenerics).forEach((genericName) => {
|
|
329
|
+
// if (componentGenerics[genericName].default) {
|
|
330
|
+
// option.props[`generic${genericName}`] = {
|
|
331
|
+
// type: String,
|
|
332
|
+
// default: `${genericName}default`
|
|
333
|
+
// }
|
|
334
|
+
// } else {
|
|
335
|
+
// option.props[`generic${genericName}`] = String
|
|
336
|
+
// }
|
|
337
|
+
// })
|
|
338
|
+
// }
|
|
339
|
+
|
|
340
|
+
if (ctorType === 'page') {
|
|
341
|
+
(option.mixins ? option.mixins : (option.mixins = [])).push({
|
|
342
|
+
// cache page instance in tenon
|
|
343
|
+
created () {
|
|
344
|
+
global.__currentPageInstance = this
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (mixin) {
|
|
352
|
+
if (option.mixins) {
|
|
353
|
+
option.mixins.push(mixin)
|
|
354
|
+
} else {
|
|
355
|
+
option.mixins = [mixin]
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (componentId) {
|
|
360
|
+
option.componentPath = '/' + componentId
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return option
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function getComponent (component, extendOptions) {
|
|
367
|
+
component = component.__esModule ? component.default : component
|
|
368
|
+
// eslint-disable-next-line
|
|
369
|
+
if (extendOptions) Object.assign(component, extendOptions)
|
|
370
|
+
return component
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function getWxsMixin (wxsModules) {
|
|
374
|
+
if (!wxsModules) return {}
|
|
375
|
+
return {
|
|
376
|
+
created () {
|
|
377
|
+
Object.keys(wxsModules).forEach((key) => {
|
|
378
|
+
if (key in this) {
|
|
379
|
+
console.error(`[Mpx runtime error]: The wxs module key [${key}] exist in the component/page instance already, please check and rename it!`)
|
|
380
|
+
} else {
|
|
381
|
+
this[key] = wxsModules[key]
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const postcss = require('postcss')
|
|
2
|
+
const rpxRegExp = /\b(\d+(\.\d+)?)rpx\b/
|
|
3
|
+
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
4
|
+
|
|
5
|
+
module.exports = postcss.plugin('hm', (options = {}) => root => {
|
|
6
|
+
function transHm (declaration) {
|
|
7
|
+
if (rpxRegExp.test(declaration.value)) {
|
|
8
|
+
declaration.value = declaration.value.replace(rpxRegExpG, function (match, $1) {
|
|
9
|
+
if ($1 === '0') return $1
|
|
10
|
+
return `${$1}hm`
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
root.walkRules(rule => {
|
|
16
|
+
rule.walkDecls(declaration => {
|
|
17
|
+
transHm(declaration)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -2180,6 +2180,15 @@ function processElement (el, root, options, meta) {
|
|
|
2180
2180
|
processComponentGenericsForWeb(el, options, meta)
|
|
2181
2181
|
return
|
|
2182
2182
|
}
|
|
2183
|
+
if (mode === 'tenon') {
|
|
2184
|
+
// 收集内建组件
|
|
2185
|
+
processBuiltInComponents(el, meta)
|
|
2186
|
+
// 预处理代码维度条件编译
|
|
2187
|
+
processIfForWeb(el)
|
|
2188
|
+
// processWebExternalClassesHack(el, options)
|
|
2189
|
+
// processComponentGenericsForWeb(el, options, meta)
|
|
2190
|
+
return
|
|
2191
|
+
}
|
|
2183
2192
|
|
|
2184
2193
|
const pass = isNative || processTemplate(el) || processingTemplate
|
|
2185
2194
|
|
|
@@ -2214,7 +2223,7 @@ function processElement (el, root, options, meta) {
|
|
|
2214
2223
|
|
|
2215
2224
|
function closeElement (el, meta) {
|
|
2216
2225
|
postProcessAtMode(el)
|
|
2217
|
-
if (mode === 'web') {
|
|
2226
|
+
if (mode === 'web' || mode === 'tenon') {
|
|
2218
2227
|
postProcessWxs(el, meta)
|
|
2219
2228
|
// 处理代码维度条件编译移除死分支
|
|
2220
2229
|
postProcessIf(el)
|
|
@@ -2321,7 +2330,7 @@ function serialize (root) {
|
|
|
2321
2330
|
result += node.text
|
|
2322
2331
|
}
|
|
2323
2332
|
}
|
|
2324
|
-
if (node.tag === 'wxs' && mode === 'web') {
|
|
2333
|
+
if (node.tag === 'wxs' && (mode === 'web' || mode === 'tenon')) {
|
|
2325
2334
|
return result
|
|
2326
2335
|
}
|
|
2327
2336
|
if (node.type === 1) {
|
|
@@ -15,7 +15,7 @@ module.exports = function transDynamicClassExpr (expr, { error } = {}) {
|
|
|
15
15
|
const propertyName = property.key.name || property.key.value
|
|
16
16
|
if (/-/.test(propertyName)) {
|
|
17
17
|
if (/\$/.test(propertyName)) {
|
|
18
|
-
error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
|
|
18
|
+
error && error(`Dynamic classname [${propertyName}] is not supported, which includes [-] char and [$] char at the same time.`)
|
|
19
19
|
} else {
|
|
20
20
|
property.key = t.identifier(propertyName.replace(/-/g, '$$') + 'MpxDash')
|
|
21
21
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const processJSON = require('./processJSON')
|
|
2
|
+
const processScript = require('./processScript')
|
|
3
|
+
const processStyles = require('./processStyles')
|
|
4
|
+
const processTemplate = require('./processTemplate')
|
|
5
|
+
|
|
6
|
+
const async = require('async')
|
|
7
|
+
|
|
8
|
+
module.exports = function ({
|
|
9
|
+
mpx,
|
|
10
|
+
loaderContext,
|
|
11
|
+
isProduction,
|
|
12
|
+
parts,
|
|
13
|
+
ctorType,
|
|
14
|
+
filePath,
|
|
15
|
+
queryObj,
|
|
16
|
+
autoScope,
|
|
17
|
+
componentsMap,
|
|
18
|
+
projectRoot,
|
|
19
|
+
getRequireForSrc,
|
|
20
|
+
vueContentCache,
|
|
21
|
+
moduleId,
|
|
22
|
+
callback
|
|
23
|
+
}) {
|
|
24
|
+
const hasComment = parts.template && parts.template.attrs && parts.template.attrs.comments
|
|
25
|
+
const isNative = false
|
|
26
|
+
const mode = mpx.mode
|
|
27
|
+
const srcMode = mpx.srcMode
|
|
28
|
+
const env = mpx.env
|
|
29
|
+
const defs = mpx.defs
|
|
30
|
+
const resolveMode = mpx.resolveMode
|
|
31
|
+
const pagesMap = mpx.pagesMap
|
|
32
|
+
|
|
33
|
+
let output = ''
|
|
34
|
+
let usingComponents = [].concat(Object.keys(mpx.usingComponents))
|
|
35
|
+
|
|
36
|
+
return async.waterfall([
|
|
37
|
+
(callback) => {
|
|
38
|
+
async.parallel([
|
|
39
|
+
(callback) => {
|
|
40
|
+
processTemplate(parts.template, {
|
|
41
|
+
hasComment,
|
|
42
|
+
isNative,
|
|
43
|
+
mode,
|
|
44
|
+
srcMode,
|
|
45
|
+
defs,
|
|
46
|
+
loaderContext,
|
|
47
|
+
moduleId,
|
|
48
|
+
ctorType,
|
|
49
|
+
usingComponents,
|
|
50
|
+
decodeHTMLText: mpx.decodeHTMLText,
|
|
51
|
+
externalClasses: mpx.externalClasses,
|
|
52
|
+
checkUsingComponents: mpx.checkUsingComponents
|
|
53
|
+
}, callback)
|
|
54
|
+
},
|
|
55
|
+
(callback) => {
|
|
56
|
+
processStyles(parts.styles, {
|
|
57
|
+
ctorType,
|
|
58
|
+
autoScope
|
|
59
|
+
}, callback)
|
|
60
|
+
},
|
|
61
|
+
(callback) => {
|
|
62
|
+
processJSON(parts.json, {
|
|
63
|
+
mode,
|
|
64
|
+
env,
|
|
65
|
+
defs,
|
|
66
|
+
resolveMode,
|
|
67
|
+
loaderContext,
|
|
68
|
+
pagesMap,
|
|
69
|
+
pagesEntryMap: mpx.pagesEntryMap,
|
|
70
|
+
pathHash: mpx.pathHash,
|
|
71
|
+
componentsMap,
|
|
72
|
+
projectRoot
|
|
73
|
+
}, callback)
|
|
74
|
+
}
|
|
75
|
+
], (err, res) => {
|
|
76
|
+
callback(err, res)
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
([templateRes, stylesRes, jsonRes], callback) => {
|
|
80
|
+
output += templateRes.output
|
|
81
|
+
output += stylesRes.output
|
|
82
|
+
output += jsonRes.output
|
|
83
|
+
if (ctorType === 'app' && jsonRes.jsonObj.window && jsonRes.jsonObj.window.navigationBarTitleText) {
|
|
84
|
+
mpx.appTitle = jsonRes.jsonObj.window.navigationBarTitleText
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
processScript(parts.script, {
|
|
88
|
+
ctorType,
|
|
89
|
+
srcMode,
|
|
90
|
+
loaderContext,
|
|
91
|
+
isProduction,
|
|
92
|
+
getRequireForSrc,
|
|
93
|
+
projectRoot,
|
|
94
|
+
jsonConfig: jsonRes.jsonObj,
|
|
95
|
+
componentId: queryObj.componentId || '',
|
|
96
|
+
builtInComponentsMap: templateRes.builtInComponentsMap,
|
|
97
|
+
localComponentsMap: jsonRes.localComponentsMap,
|
|
98
|
+
localPagesMap: jsonRes.localPagesMap,
|
|
99
|
+
forceDisableBuiltInLoader: mpx.forceDisableBuiltInLoader
|
|
100
|
+
}, callback)
|
|
101
|
+
}
|
|
102
|
+
], (err, scriptRes) => {
|
|
103
|
+
if (err) return callback(err)
|
|
104
|
+
output += scriptRes.output
|
|
105
|
+
vueContentCache.set(filePath, output)
|
|
106
|
+
callback(null, output)
|
|
107
|
+
})
|
|
108
|
+
}
|