@mpxjs/webpack-plugin 2.9.67 → 2.9.70-alpha.0

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 (161) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +51 -15
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +53 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/canvas.js +8 -0
  10. package/lib/platform/template/wx/component-config/image.js +4 -0
  11. package/lib/platform/template/wx/component-config/input.js +5 -1
  12. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  13. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  14. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  15. package/lib/platform/template/wx/component-config/switch.js +4 -0
  16. package/lib/platform/template/wx/component-config/text.js +4 -0
  17. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  18. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  19. package/lib/platform/template/wx/component-config/view.js +4 -0
  20. package/lib/platform/template/wx/index.js +127 -1
  21. package/lib/react/processStyles.js +14 -4
  22. package/lib/react/processTemplate.js +3 -0
  23. package/lib/resolve-loader.js +4 -1
  24. package/lib/resolver/AddModePlugin.js +8 -8
  25. package/lib/runtime/components/react/context.ts +6 -0
  26. package/lib/runtime/components/react/dist/context.js +2 -0
  27. package/lib/runtime/components/react/dist/event.config.js +24 -24
  28. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
  29. package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
  30. package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
  31. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
  32. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
  33. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
  34. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
  35. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
  36. package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
  37. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
  38. package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
  39. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  40. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  41. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  42. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  43. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  44. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  45. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  46. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  47. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  48. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  49. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  50. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  51. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  52. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  53. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  54. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  56. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
  57. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
  58. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  59. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  60. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  61. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  62. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  63. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  64. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  65. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  66. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  67. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  68. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  69. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  70. package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
  71. package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
  72. package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
  73. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  74. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  75. package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
  76. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  77. package/lib/runtime/components/react/dist/utils.jsx +70 -23
  78. package/lib/runtime/components/react/getInnerListeners.ts +36 -43
  79. package/lib/runtime/components/react/mpx-button.tsx +95 -43
  80. package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
  81. package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
  82. package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
  83. package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
  84. package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
  85. package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
  86. package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
  87. package/lib/runtime/components/react/mpx-canvas/index.tsx +302 -0
  88. package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
  89. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  90. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  91. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  92. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  93. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  94. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  95. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  96. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  97. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  98. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  99. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  100. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  101. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  102. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  103. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  104. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  105. package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
  106. package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
  107. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  108. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  109. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  110. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  111. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  112. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  113. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  114. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  115. package/lib/runtime/components/react/mpx-view.tsx +81 -59
  116. package/lib/runtime/components/react/mpx-web-view.tsx +46 -19
  117. package/lib/runtime/components/react/pickerFaces.ts +104 -0
  118. package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
  119. package/lib/runtime/components/react/types/common.ts +2 -0
  120. package/lib/runtime/components/react/types/global.d.ts +3 -16
  121. package/lib/runtime/components/react/utils.tsx +98 -27
  122. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  123. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  124. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  125. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  126. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  127. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  128. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  129. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  130. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  131. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  132. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  133. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  134. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  135. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  136. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  137. package/lib/runtime/optionProcessor.js +7 -16
  138. package/lib/runtime/optionProcessor.tenon.js +84 -0
  139. package/lib/runtime/utils.js +2 -0
  140. package/lib/style-compiler/index.js +1 -1
  141. package/lib/style-compiler/plugins/hm.js +20 -0
  142. package/lib/template-compiler/bind-this.js +7 -2
  143. package/lib/template-compiler/compiler.js +70 -42
  144. package/lib/template-compiler/gen-node-react.js +3 -3
  145. package/lib/tenon/index.js +117 -0
  146. package/lib/tenon/processJSON.js +352 -0
  147. package/lib/tenon/processScript.js +203 -0
  148. package/lib/tenon/processStyles.js +21 -0
  149. package/lib/tenon/processTemplate.js +126 -0
  150. package/lib/tenon/script-helper.js +223 -0
  151. package/lib/utils/env.js +6 -1
  152. package/lib/utils/get-relative-path.js +25 -0
  153. package/package.json +9 -4
  154. package/LICENSE +0 -433
  155. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  156. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  157. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  158. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  159. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  160. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  161. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -15,7 +15,7 @@ const { isNonPhrasingTag } = require('../utils/dom-tag-config')
15
15
  const setBaseWxml = require('../runtime-render/base-wxml')
16
16
  const { parseExp } = require('./parse-exps')
17
17
  const shallowStringify = require('../utils/shallow-stringify')
18
- const { isReact, isWeb } = require('../utils/env')
18
+ const { isReact, isWeb, isTenon } = require('../utils/env')
19
19
 
20
20
  const no = function () {
21
21
  return false
@@ -725,7 +725,7 @@ function parse (template, options) {
725
725
  stack.push(element)
726
726
  } else {
727
727
  element.unary = true
728
- closeElement(element, meta, options)
728
+ closeElement(element, options, meta)
729
729
  }
730
730
  },
731
731
 
@@ -740,7 +740,7 @@ function parse (template, options) {
740
740
  // pop stack
741
741
  stack.pop()
742
742
  currentParent = stack[stack.length - 1]
743
- closeElement(element, meta, options)
743
+ closeElement(element, options, meta)
744
744
  }
745
745
  },
746
746
 
@@ -765,7 +765,7 @@ function parse (template, options) {
765
765
  parent: currentParent
766
766
  }
767
767
  children.push(el)
768
- runtimeCompile ? processTextDynamic(el) : processText(el)
768
+ runtimeCompile ? processTextDynamic(el) : processText(el, options, meta)
769
769
  }
770
770
  },
771
771
  comment: function comment (text) {
@@ -1164,7 +1164,7 @@ function processEventReact (el) {
1164
1164
  configs: []
1165
1165
  }
1166
1166
  }
1167
- eventConfigMap[type].configs.push(Object.assign({ name }, parsedFunc))
1167
+ eventConfigMap[type].configs.push(Object.assign({ name, value }, parsedFunc))
1168
1168
  }
1169
1169
  }
1170
1170
  })
@@ -1205,26 +1205,31 @@ function processEventReact (el) {
1205
1205
 
1206
1206
  // let wrapper
1207
1207
  for (const type in eventConfigMap) {
1208
- let { configs } = eventConfigMap[type]
1209
- configs.forEach(({ name }) => {
1210
- if (name) {
1211
- // 清空原始事件绑定
1212
- let has
1213
- do {
1214
- has = getAndRemoveAttr(el, name).has
1215
- } while (has)
1216
- }
1217
- })
1218
- configs = configs.map((item) => {
1219
- return item.expStr
1220
- })
1221
- const value = `{{(e)=>this.__invoke(e, [${configs}])}}`
1222
- addAttrs(el, [
1223
- {
1224
- name: type,
1225
- value
1226
- }
1227
- ])
1208
+ const { configs } = eventConfigMap[type]
1209
+ if (!configs.length) continue
1210
+ const needBind = configs.length > 1 || configs[0].hasArgs
1211
+ if (needBind) {
1212
+ configs.forEach(({ name }) => {
1213
+ if (name) {
1214
+ // 清空原始事件绑定
1215
+ let has
1216
+ do {
1217
+ has = getAndRemoveAttr(el, name).has
1218
+ } while (has)
1219
+ }
1220
+ })
1221
+ const value = `{{(e)=>this.__invoke(e, [${configs.map(item => item.expStr)}])}}`
1222
+ addAttrs(el, [
1223
+ {
1224
+ name: type,
1225
+ value
1226
+ }
1227
+ ])
1228
+ } else {
1229
+ const { name, value } = configs[0]
1230
+ modifyAttr(el, name, `{{${value}}}`)
1231
+ }
1232
+
1228
1233
  // 非button的情况下,press/longPress时间需要包裹TouchableWithoutFeedback进行响应,后续可支持配置
1229
1234
  // if ((type === 'press' || type === 'longPress') && el.tag !== 'mpx-button') {
1230
1235
  // if (!wrapper) {
@@ -1374,7 +1379,8 @@ function processEvent (el, options) {
1374
1379
  function processSlotReact (el, meta) {
1375
1380
  if (el.tag === 'slot') {
1376
1381
  el.slot = {
1377
- name: getAndRemoveAttr(el, 'name').val
1382
+ name: getAndRemoveAttr(el, 'name').val,
1383
+ slot: getAndRemoveAttr(el, 'slot').val
1378
1384
  }
1379
1385
  meta.options = meta.options || {}
1380
1386
  meta.options.disableMemo = true
@@ -2035,7 +2041,7 @@ function postProcessIfReact (el) {
2035
2041
  }
2036
2042
  }
2037
2043
 
2038
- function processText (el) {
2044
+ function processText (el, options, meta) {
2039
2045
  if (el.type !== 3 || el.isComment) {
2040
2046
  return
2041
2047
  }
@@ -2045,17 +2051,32 @@ function processText (el) {
2045
2051
  }
2046
2052
  el.text = parsed.val
2047
2053
  if (isReact(mode)) {
2048
- processWrapTextReact(el)
2054
+ processWrapTextReact(el, options, meta)
2049
2055
  }
2050
2056
  }
2051
2057
 
2052
- // RN中文字需被Text包裹
2053
- function processWrapTextReact (el) {
2054
- const parentTag = el.parent.tag
2058
+ // RN中裸文字需被Text包裹
2059
+ // 为了批量修改Text默认属性,如allowFontScaling,使用mpx-simple-text进行包裹
2060
+ function processWrapTextReact (el, options, meta) {
2061
+ const parent = el.parent
2062
+ const parentTag = parent.tag
2055
2063
  if (parentTag !== 'mpx-text' && parentTag !== 'Text' && parentTag !== 'wxs') {
2056
- const wrapper = createASTElement('Text')
2064
+ const wrapper = createASTElement('mpx-simple-text')
2065
+ wrapper.isBuiltIn = true
2066
+ const dataSetAttrs = []
2067
+ parent.attrsList.forEach(({ name, value }) => {
2068
+ if (/^data-/.test(name)) {
2069
+ dataSetAttrs.push({
2070
+ name,
2071
+ value
2072
+ })
2073
+ }
2074
+ })
2075
+ addAttrs(wrapper, dataSetAttrs)
2057
2076
  replaceNode(el, wrapper, true)
2058
2077
  addChild(wrapper, el)
2078
+ processBuiltInComponents(wrapper, meta)
2079
+ processAttrs(wrapper, options)
2059
2080
  }
2060
2081
  }
2061
2082
 
@@ -2073,7 +2094,7 @@ function processWrapTextReact (el) {
2073
2094
  // }
2074
2095
 
2075
2096
  function injectWxs (meta, module, src) {
2076
- if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode)) {
2097
+ if (runtimeCompile || addWxsModule(meta, module, src) || isReact(mode) || isWeb(mode) || isTenon(mode)) {
2077
2098
  return
2078
2099
  }
2079
2100
 
@@ -2360,12 +2381,11 @@ function getVirtualHostRoot (options, meta) {
2360
2381
  {
2361
2382
  name: 'class',
2362
2383
  value: `${MPX_ROOT_VIEW} host-${moduleId}`
2384
+ },
2385
+ {
2386
+ name: 'ishost',
2387
+ value: '{{true}}'
2363
2388
  }
2364
- // todo 运行时通过root标识确定是否合并rootProps
2365
- // {
2366
- // name: 'is-root',
2367
- // value: '{{true}}'
2368
- // }
2369
2389
  ])
2370
2390
  processElement(rootView, rootView, options, meta)
2371
2391
  return rootView
@@ -2611,6 +2631,15 @@ function processElement (el, root, options, meta) {
2611
2631
  processComponentGenericsWeb(el, options, meta)
2612
2632
  return
2613
2633
  }
2634
+ if (mode === 'tenon') {
2635
+ // 收集内建组件
2636
+ processBuiltInComponents(el, meta)
2637
+ // 预处理代码维度条件编译
2638
+ processIfWeb(el)
2639
+ // processWebExternalClassesHack(el, options)
2640
+ // processComponentGenericsForWeb(el, options, meta)
2641
+ return
2642
+ }
2614
2643
 
2615
2644
  if (isReact(mode)) {
2616
2645
  const pass = isReactComponent(el, options)
@@ -2619,8 +2648,8 @@ function processElement (el, root, options, meta) {
2619
2648
  // 预处理代码维度条件编译
2620
2649
  processIf(el)
2621
2650
  processFor(el)
2651
+ processRefReact(el, meta)
2622
2652
  if (!pass) {
2623
- processRefReact(el, meta)
2624
2653
  processStyleReact(el, options)
2625
2654
  processEventReact(el)
2626
2655
  processComponentIs(el, options)
@@ -2662,11 +2691,11 @@ function processElement (el, root, options, meta) {
2662
2691
  processAttrs(el, options)
2663
2692
  }
2664
2693
 
2665
- function closeElement (el, meta, options) {
2694
+ function closeElement (el, options, meta) {
2666
2695
  postProcessAtMode(el)
2667
2696
  postProcessWxs(el, meta)
2668
2697
 
2669
- if (isWeb(mode)) {
2698
+ if (isWeb(mode) || isTenon(mode)) {
2670
2699
  // 处理代码维度条件编译移除死分支
2671
2700
  postProcessIf(el)
2672
2701
  return
@@ -2799,7 +2828,6 @@ function serialize (root) {
2799
2828
  result += node.text
2800
2829
  }
2801
2830
  }
2802
-
2803
2831
  if (node.type === 1) {
2804
2832
  if (node.tag !== 'temp-node') {
2805
2833
  result += '<' + node.tag
@@ -19,7 +19,7 @@ function genFor (node) {
19
19
  node.forProcessed = true
20
20
  const index = node.for.index || 'index'
21
21
  const item = node.for.item || 'item'
22
- return `_i(${node.for.exp}, function(${item},${index}){return ${genNode(node)}})`
22
+ return `this.__iter(${node.for.exp}, function(${item},${index}){return ${genNode(node)}})`
23
23
  }
24
24
 
25
25
  const s = JSON.stringify
@@ -56,8 +56,8 @@ function genNode (node) {
56
56
  return map
57
57
  }, {})
58
58
  if (node.slot) {
59
- const name = node.slot.name
60
- exp += `__getSlot(${name ? s(name) : ''})`
59
+ const { name, slot } = node.slot
60
+ exp += `this.__getSlot(${name ? s(name) : ''}${slot ? `, ${s(slot)}` : ''})`
61
61
  } else {
62
62
  exp += `createElement(${`getComponent(${node.is || s(node.tag)})`}`
63
63
  if (node.attrsList.length) {
@@ -0,0 +1,117 @@
1
+ const async = require('async')
2
+ const processJSON = require('./processJSON')
3
+ // const processMainScript = require('./processMainScript')
4
+ const processTemplate = require('./processTemplate')
5
+ const processStyles = require('./processStyles')
6
+ const processScript = require('./processScript')
7
+ const RecordLoaderContentDependency = require('../dependencies/RecordLoaderContentDependency')
8
+ const {stringifyRequest} = require('./script-helper')
9
+ const addQuery = require('../utils/add-query')
10
+ const parseRequest = require('../utils/parse-request')
11
+
12
+
13
+
14
+ module.exports = function ({
15
+ parts,
16
+ jsonContent,
17
+ loaderContext,
18
+ pagesMap,
19
+ componentsMap,
20
+ queryObj,
21
+ ctorType,
22
+ srcMode,
23
+ moduleId,
24
+ isProduction,
25
+ hasScoped,
26
+ hasComment,
27
+ isNative,
28
+ usingComponentsInfo,
29
+ componentGenerics,
30
+ autoScope,
31
+ callback
32
+ }) {
33
+
34
+ let output = ''
35
+
36
+
37
+ const mpx = loaderContext.getMpx()
38
+ // const hasComment = parts.template && parts.template.attrs && parts.template.attrs.comments
39
+ // const isNative = false
40
+ const mode = mpx.mode
41
+ // const srcMode = mpx.srcMode
42
+ const env = mpx.env
43
+ const defs = mpx.defs
44
+ const resolveMode = mpx.resolveMode
45
+ // const pagesMap = mpx.pagesMap
46
+ const projectRoot = mpx.projectRoot
47
+
48
+ // 通过RecordLoaderContentDependency和loaderContentCache确保子request不再重复生成loaderContent
49
+ const cacheContent = mpx.loaderContentCache.get(loaderContext.resourcePath)
50
+ if (cacheContent) return callback(null, cacheContent)
51
+ return async.waterfall([
52
+ (callback) => {
53
+ async.parallel([
54
+ (callback) => {
55
+ processTemplate(parts.template, {
56
+ loaderContext,
57
+ hasScoped,
58
+ hasComment,
59
+ isNative,
60
+ srcMode,
61
+ moduleId,
62
+ ctorType,
63
+ usingComponentsInfo,
64
+ componentGenerics
65
+ }, callback)
66
+ },
67
+ (callback) => {
68
+ processStyles(parts.styles, {
69
+ ctorType,
70
+ autoScope,
71
+ moduleId
72
+ }, callback)
73
+ },
74
+ (callback) => {
75
+ processJSON(jsonContent, {
76
+ mode,
77
+ env,
78
+ defs,
79
+ resolveMode,
80
+ loaderContext,
81
+ pagesMap,
82
+ pathHash: mpx.pathHash,
83
+ componentsMap,
84
+ projectRoot
85
+ }, callback)
86
+ }
87
+ ], (err, res) => {
88
+ callback(err, res)
89
+ })
90
+ },
91
+ ([templateRes, stylesRes, jsonRes], callback) => {
92
+ output += templateRes.output
93
+ output += stylesRes.output
94
+ output += jsonRes.output
95
+ processScript(parts.script, {
96
+ loaderContext,
97
+ ctorType,
98
+ srcMode,
99
+ moduleId,
100
+ isProduction,
101
+ componentGenerics,
102
+ jsonConfig: jsonRes.jsonObj,
103
+ outputPath: queryObj.outputPath || '',
104
+ builtInComponentsMap: templateRes.builtInComponentsMap,
105
+ localPagesMap: jsonRes.localPagesMap,
106
+ genericsInfo: templateRes.genericsInfo,
107
+ wxsModuleMap: templateRes.wxsModuleMap,
108
+ localComponentsMap: jsonRes.localComponentsMap
109
+ }, callback)
110
+ }
111
+ ], (err, scriptRes) => {
112
+ if (err) return callback(err)
113
+ output += scriptRes.output
114
+ loaderContext._module.addPresentationalDependency(new RecordLoaderContentDependency(loaderContext.resourcePath, output))
115
+ callback(null, output)
116
+ })
117
+ }