@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.
Files changed (71) hide show
  1. package/lib/config.js +24 -24
  2. package/lib/dependencies/CommonJsVariableDependency.js +1 -1
  3. package/lib/dependencies/DynamicEntryDependency.js +18 -11
  4. package/lib/extractor.js +1 -1
  5. package/lib/helpers.js +3 -1
  6. package/lib/index.js +24 -21
  7. package/lib/json-compiler/helper.js +1 -1
  8. package/lib/json-compiler/index.js +17 -17
  9. package/lib/json-compiler/plugin.js +3 -2
  10. package/lib/json-compiler/theme.js +1 -1
  11. package/lib/loader.js +3 -3
  12. package/lib/native-loader.js +1 -1
  13. package/lib/platform/json/normalize-test.js +3 -1
  14. package/lib/platform/run-rules.js +2 -2
  15. package/lib/platform/template/wx/component-config/camera.js +3 -3
  16. package/lib/platform/template/wx/component-config/canvas.js +5 -5
  17. package/lib/platform/template/wx/component-config/map.js +5 -5
  18. package/lib/platform/template/wx/component-config/navigator.js +7 -7
  19. package/lib/platform/template/wx/component-config/progress.js +4 -4
  20. package/lib/platform/template/wx/component-config/scroll-view.js +3 -3
  21. package/lib/platform/template/wx/component-config/slider.js +6 -6
  22. package/lib/platform/template/wx/component-config/swiper.js +2 -2
  23. package/lib/platform/template/wx/component-config/video.js +4 -4
  24. package/lib/platform/template/wx/component-config/view.js +4 -4
  25. package/lib/platform/template/wx/index.js +45 -13
  26. package/lib/resolver/PackageEntryPlugin.js +1 -1
  27. package/lib/runtime/components/web/filterTag.js +6 -6
  28. package/lib/runtime/components/web/getInnerListeners.js +1 -1
  29. package/lib/runtime/components/web/mpx-button.vue +0 -1
  30. package/lib/runtime/components/web/mpx-icon.vue +1 -1
  31. package/lib/runtime/components/web/mpx-keep-alive.vue +2 -2
  32. package/lib/runtime/components/web/mpx-picker.vue +1 -1
  33. package/lib/runtime/components/web/mpx-progress.vue +1 -1
  34. package/lib/runtime/components/web/mpx-scroll-view.vue +1 -1
  35. package/lib/runtime/env.js +1 -0
  36. package/lib/runtime/i18n.wxs +44 -81
  37. package/lib/runtime/optionProcessor.d.ts +0 -4
  38. package/lib/runtime/optionProcessor.js +15 -13
  39. package/lib/runtime/stringify.wxs +3 -3
  40. package/lib/runtime/swanHelper.wxs +2 -2
  41. package/lib/runtime/{components/web/util.js → utils.js} +8 -5
  42. package/lib/script-setup-compiler/index.js +1163 -0
  43. package/lib/style-compiler/index.js +1 -1
  44. package/lib/style-compiler/plugins/rpx.js +1 -1
  45. package/lib/style-compiler/plugins/vw.js +6 -4
  46. package/lib/template-compiler/bind-this.js +5 -5
  47. package/lib/template-compiler/compiler.js +122 -179
  48. package/lib/template-compiler/index.js +3 -3
  49. package/lib/utils/add-query.js +2 -1
  50. package/lib/utils/gen-component-tag.js +1 -1
  51. package/lib/utils/has-own.js +5 -0
  52. package/lib/utils/is-empty-object.js +2 -1
  53. package/lib/utils/parse-request.js +3 -3
  54. package/lib/utils/{index.js → process-defs.js} +3 -10
  55. package/lib/utils/stringify-query.js +23 -21
  56. package/lib/web/processJSON.js +5 -5
  57. package/lib/web/processScript.js +16 -19
  58. package/lib/web/processTemplate.js +1 -1
  59. package/lib/wxml/loader.js +3 -3
  60. package/lib/wxs/i18n-loader.js +4 -11
  61. package/lib/wxs/pre-loader.js +51 -44
  62. package/lib/wxss/compile-exports.js +4 -4
  63. package/lib/wxss/createResolver.js +3 -3
  64. package/lib/wxss/css-base.js +13 -13
  65. package/lib/wxss/getLocalIdent.js +5 -4
  66. package/lib/wxss/loader.js +1 -1
  67. package/lib/wxss/localsLoader.js +14 -14
  68. package/lib/wxss/processCss.js +10 -7
  69. package/package.json +4 -3
  70. package/lib/utils/env.js +0 -4
  71. package/lib/utils/parse-asset.js +0 -195
@@ -1,4 +1,5 @@
1
- import { inBrowser } from '../utils/env'
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.hasOwnProperty(componentName)) {
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
- var tmp = item.split(propertyDelimiter)
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 (let key in parsedStyleObj) {
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.hasOwnProperty(pagePath)) {
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 (inBrowser) {
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 standard/no-callback-literal */
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
- if (i18n) {
333
- option.i18n = i18n
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.hasOwnProperty(componentName)) {
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 likeArray (arr) {
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 (likeArray(value)) {
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 (likeArray(value)) {
198
+ if (isArray(value)) {
199
199
  return mergeObjectArray(value)
200
200
  }
201
201
  if (typeof value === 'string') {
@@ -1,4 +1,4 @@
1
- function likeArray (arr) {
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 (likeArray(value) || isObject(value)) {
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
- for (let key in obj) {
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
+ }