@mpxjs/webpack-plugin 2.7.52 → 2.8.0-beta.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/lib/config.js +24 -24
- package/lib/dependencies/CommonJsVariableDependency.js +1 -1
- package/lib/dependencies/DynamicEntryDependency.js +18 -11
- package/lib/extractor.js +1 -1
- package/lib/helpers.js +3 -1
- package/lib/index.js +24 -21
- package/lib/json-compiler/helper.js +1 -1
- package/lib/json-compiler/index.js +17 -17
- package/lib/json-compiler/plugin.js +3 -2
- package/lib/json-compiler/theme.js +1 -1
- package/lib/loader.js +3 -3
- package/lib/native-loader.js +1 -1
- package/lib/platform/json/normalize-test.js +3 -1
- package/lib/platform/run-rules.js +2 -2
- package/lib/platform/template/wx/component-config/camera.js +3 -3
- package/lib/platform/template/wx/component-config/canvas.js +5 -5
- package/lib/platform/template/wx/component-config/map.js +5 -5
- package/lib/platform/template/wx/component-config/navigator.js +7 -7
- package/lib/platform/template/wx/component-config/progress.js +4 -4
- package/lib/platform/template/wx/component-config/scroll-view.js +3 -3
- package/lib/platform/template/wx/component-config/slider.js +6 -6
- package/lib/platform/template/wx/component-config/swiper.js +2 -2
- package/lib/platform/template/wx/component-config/video.js +4 -4
- package/lib/platform/template/wx/component-config/view.js +4 -4
- package/lib/platform/template/wx/index.js +45 -13
- package/lib/resolver/PackageEntryPlugin.js +1 -1
- package/lib/runtime/components/web/filterTag.js +6 -6
- package/lib/runtime/components/web/getInnerListeners.js +1 -1
- package/lib/runtime/components/web/mpx-button.vue +0 -1
- package/lib/runtime/components/web/mpx-icon.vue +1 -1
- package/lib/runtime/components/web/mpx-keep-alive.vue +2 -2
- package/lib/runtime/components/web/mpx-picker.vue +1 -1
- package/lib/runtime/components/web/mpx-progress.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +1 -1
- package/lib/runtime/env.js +1 -0
- package/lib/runtime/i18n.wxs +44 -81
- package/lib/runtime/optionProcessor.d.ts +0 -4
- package/lib/runtime/optionProcessor.js +15 -13
- package/lib/runtime/stringify.wxs +3 -3
- package/lib/runtime/swanHelper.wxs +2 -2
- package/lib/runtime/{components/web/util.js → utils.js} +8 -5
- package/lib/script-setup-compiler/index.js +1163 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/rpx.js +1 -1
- package/lib/style-compiler/plugins/vw.js +6 -4
- package/lib/template-compiler/bind-this.js +5 -5
- package/lib/template-compiler/compiler.js +122 -179
- package/lib/template-compiler/index.js +3 -3
- package/lib/utils/add-query.js +2 -1
- package/lib/utils/gen-component-tag.js +1 -1
- package/lib/utils/has-own.js +5 -0
- package/lib/utils/is-empty-object.js +2 -1
- package/lib/utils/parse-request.js +3 -3
- package/lib/utils/{index.js → process-defs.js} +3 -10
- package/lib/utils/stringify-query.js +23 -21
- package/lib/web/processJSON.js +5 -5
- package/lib/web/processScript.js +16 -19
- package/lib/web/processTemplate.js +1 -1
- package/lib/wxml/loader.js +3 -3
- package/lib/wxs/i18n-loader.js +4 -11
- package/lib/wxs/pre-loader.js +51 -44
- package/lib/wxss/compile-exports.js +4 -4
- package/lib/wxss/createResolver.js +3 -3
- package/lib/wxss/css-base.js +13 -13
- package/lib/wxss/getLocalIdent.js +5 -4
- package/lib/wxss/loader.js +1 -1
- package/lib/wxss/localsLoader.js +14 -14
- package/lib/wxss/processCss.js +10 -7
- package/package.json +4 -3
- package/lib/utils/env.js +0 -4
- package/lib/utils/parse-asset.js +0 -195
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBrowser } from './env'
|
|
2
|
+
import { hasOwn } from './utils'
|
|
2
3
|
|
|
3
4
|
export default function processOption (
|
|
4
5
|
option,
|
|
@@ -13,13 +14,12 @@ export default function processOption (
|
|
|
13
14
|
genericsInfo,
|
|
14
15
|
mixin,
|
|
15
16
|
Vue,
|
|
16
|
-
VueRouter
|
|
17
|
-
i18n
|
|
17
|
+
VueRouter
|
|
18
18
|
) {
|
|
19
19
|
if (ctorType === 'app') {
|
|
20
20
|
// 对于app中的组件需要全局注册
|
|
21
21
|
for (const componentName in componentsMap) {
|
|
22
|
-
if (componentsMap
|
|
22
|
+
if (hasOwn(componentsMap, componentName)) {
|
|
23
23
|
const component = componentsMap[componentName]
|
|
24
24
|
Vue.component(componentName, component)
|
|
25
25
|
}
|
|
@@ -50,11 +50,12 @@ export default function processOption (
|
|
|
50
50
|
}
|
|
51
51
|
animates.forEach((itemAnimation) => {
|
|
52
52
|
switch (itemAnimation.type) {
|
|
53
|
-
case 'style':
|
|
53
|
+
case 'style': {
|
|
54
54
|
const [key, value] = itemAnimation.args
|
|
55
55
|
dynamicStyle[key] = value
|
|
56
56
|
property.push(key)
|
|
57
57
|
break
|
|
58
|
+
}
|
|
58
59
|
default:
|
|
59
60
|
dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
60
61
|
if (!property.includes('transform')) {
|
|
@@ -99,7 +100,7 @@ export default function processOption (
|
|
|
99
100
|
if (typeof cssText === 'string') {
|
|
100
101
|
cssText.split(listDelimiter).forEach((item) => {
|
|
101
102
|
if (item) {
|
|
102
|
-
|
|
103
|
+
const tmp = item.split(propertyDelimiter)
|
|
103
104
|
tmp.length > 1 && (parsedStyleObj[tmp[0].trim()] = tmp[1].trim())
|
|
104
105
|
}
|
|
105
106
|
})
|
|
@@ -122,7 +123,7 @@ export default function processOption (
|
|
|
122
123
|
if (style) {
|
|
123
124
|
style.forEach(item => {
|
|
124
125
|
parseStyleText(item)
|
|
125
|
-
for (
|
|
126
|
+
for (const key in parsedStyleObj) {
|
|
126
127
|
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
127
128
|
}
|
|
128
129
|
})
|
|
@@ -133,7 +134,7 @@ export default function processOption (
|
|
|
133
134
|
const routes = []
|
|
134
135
|
|
|
135
136
|
for (const pagePath in pagesMap) {
|
|
136
|
-
if (pagesMap
|
|
137
|
+
if (hasOwn(pagesMap, pagePath)) {
|
|
137
138
|
const page = pagesMap[pagePath]
|
|
138
139
|
routes.push({
|
|
139
140
|
path: '/' + pagePath,
|
|
@@ -276,7 +277,7 @@ export default function processOption (
|
|
|
276
277
|
next()
|
|
277
278
|
})
|
|
278
279
|
// 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
279
|
-
if (
|
|
280
|
+
if (isBrowser) {
|
|
280
281
|
const errorHandler = function (args, fromVue) {
|
|
281
282
|
if (global.__mpxAppCbs && global.__mpxAppCbs.error && global.__mpxAppCbs.error.length) {
|
|
282
283
|
global.__mpxAppCbs.error.forEach((cb) => {
|
|
@@ -313,7 +314,7 @@ export default function processOption (
|
|
|
313
314
|
if (global.__mpxAppCbs && global.__mpxAppCbs.show) {
|
|
314
315
|
global.__mpxAppCbs.show.forEach((cb) => {
|
|
315
316
|
// todo 实现app.onShow参数
|
|
316
|
-
/* eslint-disable
|
|
317
|
+
/* eslint-disable node/no-callback-literal */
|
|
317
318
|
cb({})
|
|
318
319
|
})
|
|
319
320
|
}
|
|
@@ -329,13 +330,14 @@ export default function processOption (
|
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
// 注入pinia
|
|
334
|
+
if (global.__mpxPinia) {
|
|
335
|
+
option.pinia = global.__mpxPinia
|
|
334
336
|
}
|
|
335
337
|
} else {
|
|
336
338
|
// 局部注册页面和组件中依赖的组件
|
|
337
339
|
for (const componentName in componentsMap) {
|
|
338
|
-
if (componentsMap
|
|
340
|
+
if (hasOwn(componentsMap, componentName)) {
|
|
339
341
|
const component = componentsMap[componentName]
|
|
340
342
|
if (!option.components) {
|
|
341
343
|
option.components = {}
|
|
@@ -81,7 +81,7 @@ function isObject (obj) {
|
|
|
81
81
|
return obj !== null && typeof obj === 'object'
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function
|
|
84
|
+
function isArray (arr) {
|
|
85
85
|
if (!__mpx_wxs__) {
|
|
86
86
|
return Array.isArray(arr)
|
|
87
87
|
} else {
|
|
@@ -95,7 +95,7 @@ function isDef (v) {
|
|
|
95
95
|
|
|
96
96
|
function stringifyDynamicClass (value) {
|
|
97
97
|
if (!value) return ''
|
|
98
|
-
if (
|
|
98
|
+
if (isArray(value)) {
|
|
99
99
|
return stringifyArray(value)
|
|
100
100
|
}
|
|
101
101
|
if (isObject(value)) {
|
|
@@ -195,7 +195,7 @@ function mergeObjectArray (arr) {
|
|
|
195
195
|
|
|
196
196
|
function normalizeDynamicStyle (value) {
|
|
197
197
|
if (!value) return {}
|
|
198
|
-
if (
|
|
198
|
+
if (isArray(value)) {
|
|
199
199
|
return mergeObjectArray(value)
|
|
200
200
|
}
|
|
201
201
|
if (typeof value === 'string') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function isArray (arr) {
|
|
2
2
|
if (!__mpx_wxs__) {
|
|
3
3
|
return Array.isArray(arr)
|
|
4
4
|
} else {
|
|
@@ -12,7 +12,7 @@ function isObject (obj) {
|
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
processFor: function (value) {
|
|
15
|
-
if (
|
|
15
|
+
if (isArray(value) || isObject(value)) {
|
|
16
16
|
return value
|
|
17
17
|
}
|
|
18
18
|
if (typeof value === 'number') {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@file web运行时组件抹平中需要用到的一些工具方法
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* 处理字符串类型的宽高数值,兼容rpx
|
|
7
3
|
* @param {object | number} size 宽高
|
|
@@ -37,8 +33,15 @@ export function isEmptyObject (obj) {
|
|
|
37
33
|
if (!obj) {
|
|
38
34
|
return true
|
|
39
35
|
}
|
|
40
|
-
|
|
36
|
+
/* eslint-disable no-unreachable-loop */
|
|
37
|
+
for (const key in obj) {
|
|
41
38
|
return false
|
|
42
39
|
}
|
|
43
40
|
return true
|
|
44
41
|
}
|
|
42
|
+
|
|
43
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
44
|
+
|
|
45
|
+
export function hasOwn (obj, key) {
|
|
46
|
+
return hasOwnProperty.call(obj, key)
|
|
47
|
+
}
|