@mpxjs/webpack-plugin 2.9.65 → 2.9.67

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 (80) hide show
  1. package/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
  2. package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
  3. package/lib/index.js +28 -8
  4. package/lib/json-compiler/index.js +2 -11
  5. package/lib/loader.js +24 -45
  6. package/lib/native-loader.js +49 -64
  7. package/lib/platform/json/wx/index.js +3 -10
  8. package/lib/platform/style/wx/index.js +32 -56
  9. package/lib/react/index.js +4 -3
  10. package/lib/react/processJSON.js +5 -13
  11. package/lib/react/processMainScript.js +7 -3
  12. package/lib/react/processScript.js +3 -4
  13. package/lib/react/processTemplate.js +6 -4
  14. package/lib/resolver/AddModePlugin.js +17 -4
  15. package/lib/runtime/components/react/context.ts +8 -0
  16. package/lib/runtime/components/react/dist/context.js +1 -0
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
  18. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +30 -17
  19. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +1 -1
  20. package/lib/runtime/components/react/dist/mpx-form.jsx +33 -24
  21. package/lib/runtime/components/react/dist/mpx-icon.jsx +1 -1
  22. package/lib/runtime/components/react/dist/mpx-image/index.jsx +1 -1
  23. package/lib/runtime/components/react/dist/mpx-input.jsx +44 -38
  24. package/lib/runtime/components/react/dist/mpx-label.jsx +10 -7
  25. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +10 -17
  26. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +378 -294
  27. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  28. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +30 -17
  29. package/lib/runtime/components/react/dist/mpx-radio.jsx +1 -1
  30. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
  31. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +58 -30
  32. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +77 -77
  33. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +1 -1
  34. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +1 -1
  35. package/lib/runtime/components/react/dist/mpx-switch.jsx +8 -1
  36. package/lib/runtime/components/react/dist/mpx-text.jsx +1 -1
  37. package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
  38. package/lib/runtime/components/react/dist/mpx-view.jsx +31 -12
  39. package/lib/runtime/components/react/dist/mpx-web-view.jsx +2 -2
  40. package/lib/runtime/components/react/dist/useAnimationHooks.js +303 -0
  41. package/lib/runtime/components/react/dist/utils.jsx +13 -3
  42. package/lib/runtime/components/react/getInnerListeners.ts +1 -0
  43. package/lib/runtime/components/react/mpx-button.tsx +1 -1
  44. package/lib/runtime/components/react/mpx-checkbox-group.tsx +52 -29
  45. package/lib/runtime/components/react/mpx-checkbox.tsx +1 -1
  46. package/lib/runtime/components/react/mpx-form.tsx +42 -34
  47. package/lib/runtime/components/react/mpx-icon.tsx +1 -1
  48. package/lib/runtime/components/react/mpx-image/index.tsx +2 -3
  49. package/lib/runtime/components/react/mpx-input.tsx +68 -66
  50. package/lib/runtime/components/react/mpx-label.tsx +11 -8
  51. package/lib/runtime/components/react/mpx-movable-area.tsx +11 -19
  52. package/lib/runtime/components/react/mpx-movable-view.tsx +456 -334
  53. package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
  54. package/lib/runtime/components/react/mpx-radio-group.tsx +55 -29
  55. package/lib/runtime/components/react/mpx-radio.tsx +1 -1
  56. package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
  57. package/lib/runtime/components/react/mpx-scroll-view.tsx +92 -37
  58. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +77 -76
  59. package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
  60. package/lib/runtime/components/react/mpx-swiper-item.tsx +1 -1
  61. package/lib/runtime/components/react/mpx-switch.tsx +10 -2
  62. package/lib/runtime/components/react/mpx-text.tsx +1 -1
  63. package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
  64. package/lib/runtime/components/react/mpx-view.tsx +40 -20
  65. package/lib/runtime/components/react/mpx-web-view.tsx +2 -2
  66. package/lib/runtime/components/react/types/common.ts +8 -2
  67. package/lib/runtime/components/react/useAnimationHooks.ts +332 -0
  68. package/lib/runtime/components/react/useNodesRef.ts +1 -0
  69. package/lib/runtime/components/react/utils.tsx +23 -6
  70. package/lib/runtime/optionProcessorReact.js +0 -15
  71. package/lib/runtime/swanHelper.wxs +1 -1
  72. package/lib/style-compiler/index.js +1 -1
  73. package/lib/style-compiler/plugins/scope-id.js +1 -0
  74. package/lib/template-compiler/compiler.js +68 -33
  75. package/lib/template-compiler/index.js +4 -4
  76. package/lib/utils/pre-process-json.js +113 -0
  77. package/lib/web/index.js +5 -4
  78. package/lib/web/processJSON.js +5 -13
  79. package/lib/web/processTemplate.js +2 -2
  80. package/package.json +5 -4
@@ -101,6 +101,7 @@ let moduleId
101
101
  let isNative
102
102
  let hasScoped
103
103
  let hasVirtualHost
104
+ let isCustomText
104
105
  let runtimeCompile
105
106
  let rulesRunner
106
107
  let currentEl
@@ -115,6 +116,7 @@ let i18nInjectableComputed = []
115
116
  let hasOptionalChaining = false
116
117
  let processingTemplate = false
117
118
  const rulesResultMap = new Map()
119
+ let usingComponents = []
118
120
 
119
121
  function updateForScopesMap () {
120
122
  forScopesMap = {}
@@ -617,6 +619,7 @@ function parse (template, options) {
617
619
  isNative = options.isNative
618
620
  hasScoped = options.hasScoped
619
621
  hasVirtualHost = options.hasVirtualHost
622
+ isCustomText = options.isCustomText
620
623
  filePath = options.filePath
621
624
  i18n = options.i18n
622
625
  runtimeCompile = options.runtimeCompile
@@ -631,6 +634,9 @@ function parse (template, options) {
631
634
  processingTemplate = false
632
635
  rulesResultMap.clear()
633
636
 
637
+ if (typeof options.usingComponentsInfo === 'string') options.usingComponentsInfo = JSON.parse(options.usingComponentsInfo)
638
+ usingComponents = Object.keys(options.usingComponentsInfo)
639
+
634
640
  const _warn = content => {
635
641
  const currentElementRuleResult = rulesResultMap.get(currentEl) || rulesResultMap.set(currentEl, {
636
642
  warnArray: [],
@@ -652,7 +658,7 @@ function parse (template, options) {
652
658
  type: 'template',
653
659
  testKey: 'tag',
654
660
  data: {
655
- usingComponents: options.usingComponents
661
+ usingComponents
656
662
  },
657
663
  warn: _warn,
658
664
  error: _error
@@ -661,6 +667,14 @@ function parse (template, options) {
661
667
  const stack = []
662
668
  let root
663
669
  const meta = {}
670
+ if (isCustomText) {
671
+ meta.options = meta.options || {}
672
+ meta.options.isCustomText = true
673
+ }
674
+ if (hasVirtualHost) {
675
+ meta.options = meta.options || {}
676
+ meta.options.virtualHost = true
677
+ }
664
678
  let currentParent
665
679
  let multiRootError
666
680
  // 用于记录模板用到的组件,匹配引用组件,看是否有冗余
@@ -736,23 +750,22 @@ function parse (template, options) {
736
750
  const children = currentParent.children
737
751
  if (currentParent.tag !== 'text') {
738
752
  text = text.trim()
753
+ } else {
754
+ text = text.trim() ? text : ''
739
755
  }
740
-
741
756
  if ((!config[mode].wxs || currentParent.tag !== config[mode].wxs.tag) && options.decodeHTMLText) {
742
757
  text = he.decode(text)
743
758
  }
744
759
 
745
760
  if (text) {
746
- if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
747
- const el = {
748
- type: 3,
749
- // 支付宝小程序模板解析中未对Mustache进行特殊处理,无论是否decode都会解析失败,无解,只能支付宝侧进行修复
750
- text: decodeInMustache(text),
751
- parent: currentParent
752
- }
753
- children.push(el)
754
- runtimeCompile ? processTextDynamic(el) : processText(el)
761
+ const el = {
762
+ type: 3,
763
+ // 支付宝小程序模板解析中未对Mustache进行特殊处理,无论是否decode都会解析失败,无解,只能支付宝侧进行修复
764
+ text: decodeInMustache(text),
765
+ parent: currentParent
755
766
  }
767
+ children.push(el)
768
+ runtimeCompile ? processTextDynamic(el) : processText(el)
756
769
  }
757
770
  },
758
771
  comment: function comment (text) {
@@ -795,7 +808,7 @@ function parse (template, options) {
795
808
 
796
809
  if (!tagNames.has('component') && options.checkUsingComponents) {
797
810
  const arr = []
798
- options.usingComponents.forEach((item) => {
811
+ usingComponents.forEach((item) => {
799
812
  if (!tagNames.has(item) && !options.globalComponents.includes(item) && !options.componentPlaceholder.includes(item)) {
800
813
  arr.push(item)
801
814
  }
@@ -971,7 +984,7 @@ function processComponentIs (el, options) {
971
984
 
972
985
  const range = getAndRemoveAttr(el, 'range').val
973
986
  const isInRange = makeMap(range || '')
974
- el.components = (options.usingComponents || []).filter(i => {
987
+ el.components = (usingComponents).filter(i => {
975
988
  if (!range) return true
976
989
  return isInRange(i)
977
990
  })
@@ -1754,6 +1767,15 @@ function processRefReact (el, meta) {
1754
1767
  value: `{{ this.__getRefVal('${type}', [${selectorsConf}]) }}`
1755
1768
  }])
1756
1769
  }
1770
+
1771
+ if (el.tag === 'mpx-scroll-view' && el.attrsMap['scroll-into-view']) {
1772
+ addAttrs(el, [
1773
+ {
1774
+ name: '__selectRef',
1775
+ value: '{{ this.__selectRef.bind(this) }}'
1776
+ }
1777
+ ])
1778
+ }
1757
1779
  }
1758
1780
 
1759
1781
  function processRef (el, options, meta) {
@@ -2128,7 +2150,7 @@ function processStyle (el, meta) {
2128
2150
  }
2129
2151
 
2130
2152
  function isRealNode (el) {
2131
- const virtualNodeTagMap = ['block', 'template', 'import', config[mode].wxs.tag].reduce((map, item) => {
2153
+ const virtualNodeTagMap = ['block', 'template', 'import', 'slot', config[mode].wxs.tag].reduce((map, item) => {
2132
2154
  map[item] = true
2133
2155
  return map
2134
2156
  }, {})
@@ -2136,7 +2158,11 @@ function isRealNode (el) {
2136
2158
  }
2137
2159
 
2138
2160
  function isComponentNode (el, options) {
2139
- return options.usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
2161
+ return usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
2162
+ }
2163
+
2164
+ function isReactComponent (el, options) {
2165
+ return !isComponentNode(el, options) && isRealNode(el) && !el.isBuiltIn
2140
2166
  }
2141
2167
 
2142
2168
  function processExternalClasses (el, options) {
@@ -2254,8 +2280,10 @@ function postProcessAliComponentRootView (el, options, meta) {
2254
2280
  { condition: /^style$/, action: 'move' },
2255
2281
  { condition: /^slot$/, action: 'move' }
2256
2282
  ]
2283
+ const tagName = el.tag
2284
+ const mid = options.usingComponentsInfo[tagName]?.mid || moduleId
2257
2285
  const processAppendAttrsRules = [
2258
- { name: 'class', value: `${MPX_ROOT_VIEW} host-${moduleId}` }
2286
+ { name: 'class', value: `${MPX_ROOT_VIEW} host-${mid}` }
2259
2287
  ]
2260
2288
  const newAttrs = []
2261
2289
  const allAttrs = cloneAttrsList(el.attrsList)
@@ -2311,11 +2339,6 @@ function postProcessAliComponentRootView (el, options, meta) {
2311
2339
  function getVirtualHostRoot (options, meta) {
2312
2340
  if (srcMode === 'wx') {
2313
2341
  if (ctorType === 'component') {
2314
- if (mode === 'wx' && hasVirtualHost) {
2315
- // wx组件注入virtualHost配置
2316
- meta.options = meta.options || {}
2317
- meta.options.virtualHost = true
2318
- }
2319
2342
  if (isWeb(mode) && !hasVirtualHost) {
2320
2343
  // ali组件根节点实体化
2321
2344
  const rootView = createASTElement('view', [
@@ -2332,7 +2355,8 @@ function getVirtualHostRoot (options, meta) {
2332
2355
  return rootView
2333
2356
  }
2334
2357
  if (isReact(mode) && !hasVirtualHost) {
2335
- const rootView = createASTElement('view', [
2358
+ const tagName = isCustomText ? 'text' : 'view'
2359
+ const rootView = createASTElement(tagName, [
2336
2360
  {
2337
2361
  name: 'class',
2338
2362
  value: `${MPX_ROOT_VIEW} host-${moduleId}`
@@ -2526,7 +2550,7 @@ function processDuplicateAttrsList (el) {
2526
2550
  }
2527
2551
 
2528
2552
  // 处理wxs注入逻辑
2529
- function processInjectWxs (el, meta, options) {
2553
+ function processInjectWxs (el, meta) {
2530
2554
  if (el.injectWxsProps && el.injectWxsProps.length) {
2531
2555
  el.injectWxsProps.forEach((injectWxsProp) => {
2532
2556
  const { injectWxsPath, injectWxsModuleName } = injectWxsProp
@@ -2589,16 +2613,19 @@ function processElement (el, root, options, meta) {
2589
2613
  }
2590
2614
 
2591
2615
  if (isReact(mode)) {
2616
+ const pass = isReactComponent(el, options)
2592
2617
  // 收集内建组件
2593
2618
  processBuiltInComponents(el, meta)
2594
2619
  // 预处理代码维度条件编译
2595
2620
  processIf(el)
2596
2621
  processFor(el)
2597
- processRefReact(el, meta)
2598
- processStyleReact(el, options)
2599
- processEventReact(el)
2600
- processComponentIs(el, options)
2601
- processSlotReact(el, meta)
2622
+ if (!pass) {
2623
+ processRefReact(el, meta)
2624
+ processStyleReact(el, options)
2625
+ processEventReact(el)
2626
+ processComponentIs(el, options)
2627
+ processSlotReact(el, meta)
2628
+ }
2602
2629
  processAttrs(el, options)
2603
2630
  return
2604
2631
  }
@@ -2651,11 +2678,19 @@ function closeElement (el, meta, options) {
2651
2678
  }
2652
2679
 
2653
2680
  const isTemplate = postProcessTemplate(el) || processingTemplate
2654
- if (!isNative && !isTemplate) {
2655
- if (isComponentNode(el, options) && !hasVirtualHost && mode === 'ali') {
2681
+ if (!isTemplate) {
2682
+ if (!isNative) {
2683
+ postProcessComponentIs(el, (child) => {
2684
+ if (!hasVirtualHost && mode === 'ali') {
2685
+ postProcessAliComponentRootView(child, options)
2686
+ } else {
2687
+ postProcessIf(child)
2688
+ }
2689
+ })
2690
+ }
2691
+ if (isComponentNode(el, options) && !hasVirtualHost && mode === 'ali' && el.tag !== 'component') {
2656
2692
  postProcessAliComponentRootView(el, options, meta)
2657
2693
  }
2658
- postProcessComponentIs(el)
2659
2694
  }
2660
2695
 
2661
2696
  if (runtimeCompile) {
@@ -2702,7 +2737,7 @@ function cloneAttrsList (attrsList) {
2702
2737
  })
2703
2738
  }
2704
2739
 
2705
- function postProcessComponentIs (el) {
2740
+ function postProcessComponentIs (el, postProcessChild) {
2706
2741
  if (el.is && el.components) {
2707
2742
  let tempNode
2708
2743
  if (el.for || el.if || el.elseif || el.else) {
@@ -2724,7 +2759,7 @@ function postProcessComponentIs (el) {
2724
2759
  })
2725
2760
  newChild.exps = el.exps
2726
2761
  addChild(tempNode, newChild)
2727
- postProcessIf(newChild)
2762
+ postProcessChild(newChild)
2728
2763
  })
2729
2764
 
2730
2765
  if (!el.parent) {
@@ -24,14 +24,14 @@ module.exports = function (raw) {
24
24
  const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
25
25
  const wxsContentMap = mpx.wxsContentMap
26
26
  const optimizeRenderRules = mpx.optimizeRenderRules
27
- const usingComponents = queryObj.usingComponents || []
27
+ const usingComponentsInfo = queryObj.usingComponentsInfo || {}
28
28
  const componentPlaceholder = queryObj.componentPlaceholder || []
29
29
  const hasComment = queryObj.hasComment
30
30
  const isNative = queryObj.isNative
31
31
  const ctorType = queryObj.ctorType
32
32
  const hasScoped = queryObj.hasScoped
33
33
  const runtimeCompile = queryObj.isDynamic
34
- const moduleId = queryObj.moduleId || '_' + mpx.pathHash(resourcePath)
34
+ const moduleId = queryObj.moduleId || mpx.getModuleId(resourcePath)
35
35
 
36
36
  let optimizeRenderLevel = 0
37
37
  for (const rule of optimizeRenderRules) {
@@ -57,7 +57,6 @@ module.exports = function (raw) {
57
57
  warn,
58
58
  error,
59
59
  runtimeCompile,
60
- usingComponents,
61
60
  componentPlaceholder,
62
61
  hasComment,
63
62
  isNative,
@@ -70,11 +69,12 @@ module.exports = function (raw) {
70
69
  externalClasses,
71
70
  hasScoped,
72
71
  moduleId,
72
+ usingComponentsInfo,
73
73
  // 这里需传递resourcePath和wxsContentMap保持一致
74
74
  filePath: resourcePath,
75
75
  i18n,
76
76
  checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
77
- globalComponents: Object.keys(mpx.usingComponents),
77
+ globalComponents: Object.keys(mpx.globalComponents),
78
78
  forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules) || runtimeCompile,
79
79
  hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules),
80
80
  dynamicTemplateRuleRunner: mpx.dynamicTemplateRuleRunner
@@ -0,0 +1,113 @@
1
+ const RecordGlobalComponentsDependency = require('../dependencies/RecordGlobalComponentsDependency')
2
+ const JSON5 = require('json5')
3
+ const isUrlRequest = require('./is-url-request')
4
+ const parseRequest = require('./parse-request')
5
+ const addQuery = require('./add-query')
6
+ const resolve = require('./resolve')
7
+ const getJSONContent = require('./get-json-content')
8
+ const getRulesRunner = require('../platform')
9
+ const async = require('async')
10
+
11
+ module.exports = function ({
12
+ json,
13
+ srcMode,
14
+ emitWarning,
15
+ emitError,
16
+ ctorType,
17
+ resourcePath,
18
+ loaderContext
19
+ }, callback) {
20
+ const mpx = loaderContext.getMpx()
21
+ const context = loaderContext.context
22
+ const mode = mpx.mode
23
+ const pagesMap = mpx.pagesMap
24
+ async.waterfall([
25
+ (callback) => {
26
+ getJSONContent(json, null, loaderContext, callback)
27
+ },
28
+ (jsonContent, callback) => {
29
+ if (!jsonContent) return callback(null, {})
30
+ let componentPlaceholder = []
31
+ let componentGenerics = {}
32
+ const usingComponentsInfo = {}
33
+ const usingComponents = {}
34
+ const finalCallback = (err) => {
35
+ if (err) return callback(err)
36
+ if (ctorType === 'app') {
37
+ // 在 rulesRunner 运行后保存全局注册组件
38
+ // todo 其余地方在使用mpx.globalComponents时存在缓存问题,要规避该问题需要在所有使用mpx.globalComponents的loader中添加app resourcePath作为fileDependency,但对于缓存有效率影响巨大
39
+ // todo 需要考虑一种精准控制缓存的方式,仅在全局组件发生变更时才使相关使用方的缓存失效,例如按需在相关模块上动态添加request query?
40
+ loaderContext._module.addPresentationalDependency(new RecordGlobalComponentsDependency(usingComponents, usingComponentsInfo, context))
41
+ }
42
+ callback(null, {
43
+ componentPlaceholder,
44
+ componentGenerics,
45
+ usingComponentsInfo: Object.assign({}, usingComponentsInfo, mpx.globalComponentsInfo),
46
+ jsonContent
47
+ })
48
+ }
49
+ try {
50
+ const ret = JSON5.parse(jsonContent)
51
+ const rulesMeta = {}
52
+ const rulesRunnerOptions = {
53
+ mode,
54
+ srcMode,
55
+ type: 'json',
56
+ waterfall: true,
57
+ warn: emitWarning,
58
+ error: emitError,
59
+ meta: rulesMeta
60
+ }
61
+ if (ctorType !== 'app') {
62
+ rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
63
+ }
64
+ const rulesRunner = getRulesRunner(rulesRunnerOptions)
65
+ try {
66
+ if (rulesRunner) rulesRunner(ret)
67
+ } catch (e) {
68
+ return finalCallback(e)
69
+ }
70
+ // 不支持全局组件的平台,runRules 时会删除 app.json 中的 usingComponents, 同时 fillGlobalComponents 方法会对 rulesMeta 赋值 usingComponents,通过 rulesMeta 来重新获取 globalComponents
71
+ // page | component 时 直接获取 ret.usingComponents 内容
72
+ Object.assign(usingComponents, ret.usingComponents || rulesMeta.usingComponents)
73
+
74
+ if (ret.componentPlaceholder) {
75
+ componentPlaceholder = componentPlaceholder.concat(Object.values(ret.componentPlaceholder))
76
+ }
77
+ if (ret.componentGenerics) {
78
+ componentGenerics = Object.assign({}, ret.componentGenerics)
79
+ }
80
+ if (usingComponents) {
81
+ const setUsingComponentInfo = (name, moduleId) => {
82
+ usingComponentsInfo[name] = { mid: moduleId }
83
+ }
84
+ async.eachOf(usingComponents, (component, name, callback) => {
85
+ if (ctorType === 'app') {
86
+ usingComponents[name] = addQuery(component, {
87
+ context
88
+ })
89
+ }
90
+ if (!isUrlRequest(component)) {
91
+ const moduleId = mpx.getModuleId(component, ctorType === 'app')
92
+ setUsingComponentInfo(name, moduleId)
93
+ return callback()
94
+ }
95
+ resolve(context, component, loaderContext, (err, resource) => {
96
+ if (err) return callback(err)
97
+ const { rawResourcePath } = parseRequest(resource)
98
+ const moduleId = mpx.getModuleId(rawResourcePath, ctorType === 'app')
99
+ setUsingComponentInfo(name, moduleId)
100
+ callback()
101
+ })
102
+ }, (err) => {
103
+ finalCallback(err)
104
+ })
105
+ } else {
106
+ finalCallback()
107
+ }
108
+ } catch (err) {
109
+ finalCallback(err)
110
+ }
111
+ }
112
+ ], callback)
113
+ }
package/lib/web/index.js CHANGED
@@ -8,6 +8,7 @@ const RecordLoaderContentDependency = require('../dependencies/RecordLoaderConte
8
8
 
9
9
  module.exports = function ({
10
10
  parts,
11
+ jsonContent,
11
12
  loaderContext,
12
13
  pagesMap,
13
14
  componentsMap,
@@ -19,7 +20,7 @@ module.exports = function ({
19
20
  hasScoped,
20
21
  hasComment,
21
22
  isNative,
22
- usingComponents,
23
+ usingComponentsInfo,
23
24
  componentGenerics,
24
25
  autoScope,
25
26
  callback
@@ -27,7 +28,7 @@ module.exports = function ({
27
28
  if (ctorType === 'app' && !queryObj.isApp) {
28
29
  return async.waterfall([
29
30
  (callback) => {
30
- processJSON(parts.json, {
31
+ processJSON(jsonContent, {
31
32
  loaderContext,
32
33
  ctorType,
33
34
  pagesMap,
@@ -68,7 +69,7 @@ module.exports = function ({
68
69
  srcMode,
69
70
  moduleId,
70
71
  ctorType,
71
- usingComponents,
72
+ usingComponentsInfo,
72
73
  componentGenerics
73
74
  }, callback)
74
75
  },
@@ -80,7 +81,7 @@ module.exports = function ({
80
81
  }, callback)
81
82
  },
82
83
  (callback) => {
83
- processJSON(parts.json, {
84
+ processJSON(jsonContent, {
84
85
  loaderContext,
85
86
  ctorType,
86
87
  pagesMap,
@@ -12,9 +12,8 @@ const createJSONHelper = require('../json-compiler/helper')
12
12
  const getRulesRunner = require('../platform/index')
13
13
  const { RESOLVE_IGNORED_ERR } = require('../utils/const')
14
14
  const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
15
- const RecordGlobalComponentsDependency = require('../dependencies/RecordGlobalComponentsDependency')
16
15
 
17
- module.exports = function (json, {
16
+ module.exports = function (jsonContent, {
18
17
  loaderContext,
19
18
  ctorType,
20
19
  pagesMap,
@@ -82,12 +81,11 @@ module.exports = function (json, {
82
81
 
83
82
  const isApp = ctorType === 'app'
84
83
 
85
- if (!json) {
84
+ if (!jsonContent) {
86
85
  return callback()
87
86
  }
88
- // 由于json需要提前读取在template处理中使用,src的场景已经在loader中处理了,此处无需考虑json.src的场景
89
87
  try {
90
- jsonObj = JSON5.parse(json.content)
88
+ jsonObj = JSON5.parse(jsonContent)
91
89
  // 处理runner
92
90
  const rulesRunnerOptions = {
93
91
  mode,
@@ -97,8 +95,8 @@ module.exports = function (json, {
97
95
  warn: emitWarning,
98
96
  error: emitError,
99
97
  data: {
100
- // polyfill global usingComponents & record globalComponents
101
- globalComponents: mpx.usingComponents
98
+ // polyfill global usingComponents
99
+ globalComponents: mpx.globalComponents
102
100
  }
103
101
  }
104
102
 
@@ -111,12 +109,6 @@ module.exports = function (json, {
111
109
  if (rulesRunner) {
112
110
  rulesRunner(jsonObj)
113
111
  }
114
- if (isApp) {
115
- // 收集全局组件
116
- Object.assign(mpx.usingComponents, jsonObj.usingComponents)
117
- // 在 rulesRunner 运行后保存全局注册组件
118
- loaderContext._module.addPresentationalDependency(new RecordGlobalComponentsDependency(mpx.usingComponents, loaderContext.context))
119
- }
120
112
  } catch (e) {
121
113
  return callback(e)
122
114
  }
@@ -12,7 +12,7 @@ module.exports = function (template, {
12
12
  srcMode,
13
13
  moduleId,
14
14
  ctorType,
15
- usingComponents,
15
+ usingComponentsInfo,
16
16
  componentGenerics
17
17
  }, callback) {
18
18
  const mpx = loaderContext.getMpx()
@@ -73,7 +73,7 @@ module.exports = function (template, {
73
73
  const { root, meta } = templateCompiler.parse(template.content, {
74
74
  warn,
75
75
  error,
76
- usingComponents,
76
+ usingComponentsInfo, // processTemplate中无其他地方使用,直接透传 string 类型
77
77
  hasComment,
78
78
  isNative,
79
79
  ctorType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.65",
3
+ "version": "2.9.67",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -28,7 +28,7 @@
28
28
  "@better-scroll/wheel": "^2.5.1",
29
29
  "@better-scroll/zoom": "^2.5.1",
30
30
  "@mpxjs/template-engine": "^2.8.7",
31
- "@mpxjs/utils": "^2.9.65",
31
+ "@mpxjs/utils": "^2.9.67",
32
32
  "acorn": "^8.11.3",
33
33
  "acorn-walk": "^7.2.0",
34
34
  "async": "^2.6.0",
@@ -82,13 +82,14 @@
82
82
  },
83
83
  "devDependencies": {
84
84
  "@ant-design/react-native": "^5.2.2",
85
- "@mpxjs/api-proxy": "^2.9.65",
85
+ "@mpxjs/api-proxy": "^2.9.67",
86
86
  "@types/babel-traverse": "^6.25.4",
87
87
  "@types/babel-types": "^7.0.4",
88
88
  "@types/react": "^18.2.79",
89
89
  "react-native": "^0.74.5",
90
90
  "react-native-gesture-handler": "^2.18.1",
91
91
  "react-native-linear-gradient": "^2.8.3",
92
+ "react-native-reanimated": "^3.15.2",
92
93
  "react-native-safe-area-context": "^4.12.0",
93
94
  "react-native-webview": "^13.12.2",
94
95
  "rimraf": "^6.0.1"
@@ -96,5 +97,5 @@
96
97
  "engines": {
97
98
  "node": ">=14.14.0"
98
99
  },
99
- "gitHead": "24efa90e90b4d42c285ca61739cb9e4d0696976c"
100
+ "gitHead": "b23d3850c16543c5998811b8d1d8e6ee7988c0f8"
100
101
  }