@mpxjs/webpack-plugin 2.10.16-beta.7 → 2.10.16-perf.1
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 +0 -60
- package/lib/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/file-loader.js +3 -13
- package/lib/helpers.js +0 -2
- package/lib/index.js +15 -40
- package/lib/json-compiler/helper.js +2 -72
- package/lib/json-compiler/index.js +56 -16
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +4 -10
- package/lib/native-loader.js +3 -6
- package/lib/platform/json/wx/index.js +29 -30
- package/lib/platform/style/wx/index.js +1 -8
- package/lib/platform/template/wx/component-config/ad.js +0 -5
- package/lib/platform/template/wx/component-config/button.js +5 -21
- package/lib/platform/template/wx/component-config/camera.js +3 -25
- package/lib/platform/template/wx/component-config/canvas.js +1 -8
- package/lib/platform/template/wx/component-config/component.js +33 -31
- package/lib/platform/template/wx/component-config/cover-image.js +2 -7
- package/lib/platform/template/wx/component-config/cover-view.js +1 -3
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
- package/lib/platform/template/wx/component-config/form.js +2 -27
- package/lib/platform/template/wx/component-config/image.js +0 -5
- package/lib/platform/template/wx/component-config/input.js +0 -10
- package/lib/platform/template/wx/component-config/label.js +2 -10
- package/lib/platform/template/wx/component-config/map.js +0 -11
- package/lib/platform/template/wx/component-config/movable-area.js +1 -4
- package/lib/platform/template/wx/component-config/movable-view.js +2 -17
- package/lib/platform/template/wx/component-config/navigator.js +0 -26
- package/lib/platform/template/wx/component-config/picker-view.js +0 -12
- package/lib/platform/template/wx/component-config/picker.js +1 -3
- package/lib/platform/template/wx/component-config/progress.js +1 -11
- package/lib/platform/template/wx/component-config/rich-text.js +0 -5
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -12
- package/lib/platform/template/wx/component-config/slider.js +0 -8
- package/lib/platform/template/wx/component-config/swiper-item.js +2 -5
- package/lib/platform/template/wx/component-config/swiper.js +0 -10
- package/lib/platform/template/wx/component-config/text.js +0 -5
- package/lib/platform/template/wx/component-config/textarea.js +2 -19
- package/lib/platform/template/wx/component-config/unsupported.js +1 -10
- package/lib/platform/template/wx/component-config/video.js +0 -10
- package/lib/platform/template/wx/index.js +1 -21
- package/lib/react/index.js +0 -2
- package/lib/react/processJSON.js +71 -39
- package/lib/react/processStyles.js +2 -3
- package/lib/react/processTemplate.js +6 -8
- package/lib/react/script-helper.js +16 -6
- package/lib/react/style-helper.js +2 -10
- package/lib/runtime/components/react/context.ts +6 -12
- package/lib/runtime/components/react/dist/context.js +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +62 -100
- package/lib/runtime/components/react/dist/mpx-input.jsx +9 -35
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -58
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +18 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +11 -8
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +1 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +14 -6
- package/lib/runtime/components/react/dist/mpx-text.jsx +5 -33
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +6 -16
- package/lib/runtime/components/react/mpx-image.tsx +82 -123
- package/lib/runtime/components/react/mpx-input.tsx +16 -41
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -66
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +2 -5
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +21 -26
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +12 -8
- package/lib/runtime/components/react/mpx-portal/index.tsx +2 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +17 -6
- package/lib/runtime/components/react/mpx-text.tsx +5 -38
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/types/common.d.ts +0 -19
- package/lib/runtime/components/react/utils.tsx +6 -15
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +2 -3
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +2 -10
- package/lib/style-compiler/strip-conditional-loader.js +15 -178
- package/lib/template-compiler/bind-this.js +2 -2
- package/lib/template-compiler/compiler.js +72 -270
- package/lib/template-compiler/gen-node-react.js +6 -18
- package/lib/template-compiler/index.js +10 -12
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/const.js +1 -2
- package/lib/utils/dom-tag-config.js +6 -6
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +0 -5
- package/lib/web/index.js +0 -2
- package/lib/web/processJSON.js +16 -44
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +4 -6
- package/lib/web/script-helper.js +9 -19
- package/lib/wxs/pre-loader.js +1 -1
- package/lib/wxss/loader.js +9 -1
- package/package.json +4 -15
- package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
- package/lib/runtime/components/react/dist/context.d.ts +0 -75
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -8
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -8
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -69
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -28
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -102
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -11
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -28
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -22
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -50
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -66
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.jsx +0 -132
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -107
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +0 -20
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -30
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -25
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -55
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -31
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -18
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -102
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -35
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -40
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -12
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +0 -123
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/mpx-camera.tsx +0 -167
- package/lib/runtime/components/react/mpx-nav.tsx +0 -155
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -55
- package/lib/utils/get-build-tag-component.js +0 -35
package/lib/config.js
CHANGED
|
@@ -553,66 +553,6 @@ module.exports = {
|
|
|
553
553
|
show: 'dd:show'
|
|
554
554
|
}
|
|
555
555
|
},
|
|
556
|
-
ks: {
|
|
557
|
-
typeExtMap: {
|
|
558
|
-
json: '.json',
|
|
559
|
-
script: '.js',
|
|
560
|
-
template: '.ksml',
|
|
561
|
-
styles: '.css'
|
|
562
|
-
},
|
|
563
|
-
tabBar: {
|
|
564
|
-
itemKey: 'list',
|
|
565
|
-
iconKey: 'iconPath',
|
|
566
|
-
activeIconKey: 'selectedIconPath'
|
|
567
|
-
},
|
|
568
|
-
event: {
|
|
569
|
-
parseEvent (attr) {
|
|
570
|
-
const match = /^(bind|catch|capture-bind|capture-catch):?(.*?)(?:\.(.*))?$/.exec(attr)
|
|
571
|
-
if (match) {
|
|
572
|
-
return {
|
|
573
|
-
prefix: match[1],
|
|
574
|
-
eventName: match[2],
|
|
575
|
-
modifier: match[3]
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
},
|
|
579
|
-
getEvent (eventName, prefix = 'bind') {
|
|
580
|
-
if (eventName.includes('-')) {
|
|
581
|
-
return `${prefix}:${eventName}`
|
|
582
|
-
} else {
|
|
583
|
-
return prefix + eventName
|
|
584
|
-
}
|
|
585
|
-
},
|
|
586
|
-
defaultModelProp: 'value',
|
|
587
|
-
defaultModelEvent: 'input',
|
|
588
|
-
defaultModelValuePath: 'value'
|
|
589
|
-
},
|
|
590
|
-
wxs: {
|
|
591
|
-
tag: 'ks',
|
|
592
|
-
module: 'module',
|
|
593
|
-
src: 'src',
|
|
594
|
-
ext: '.ks',
|
|
595
|
-
templatePrefix: 'module.exports = \n'
|
|
596
|
-
},
|
|
597
|
-
directive: {
|
|
598
|
-
if: 'ks:if',
|
|
599
|
-
elseif: 'ks:elif',
|
|
600
|
-
else: 'ks:else',
|
|
601
|
-
for: 'ks:for',
|
|
602
|
-
forIndex: 'ks:for-index',
|
|
603
|
-
forItem: 'ks:for-item',
|
|
604
|
-
key: 'ks:key',
|
|
605
|
-
dynamicClass: 'ks:class',
|
|
606
|
-
dynamicStyle: 'ks:style',
|
|
607
|
-
ref: 'ks:ref',
|
|
608
|
-
show: 'ks:show',
|
|
609
|
-
model: 'ks:model',
|
|
610
|
-
modelProp: 'ks:model-prop',
|
|
611
|
-
modelEvent: 'ks:model-event',
|
|
612
|
-
modelValuePath: 'ks:model-value-path',
|
|
613
|
-
modelFilter: 'ks:model-filter'
|
|
614
|
-
}
|
|
615
|
-
},
|
|
616
556
|
ios: reactConfig,
|
|
617
557
|
android: reactConfig,
|
|
618
558
|
harmony: reactConfig
|
|
@@ -21,8 +21,8 @@ class AppEntryDependency extends NullDependency {
|
|
|
21
21
|
if (mpx.appInfo.name) {
|
|
22
22
|
const issuer = moduleGraph.getIssuer(module)
|
|
23
23
|
const err = new Error(issuer
|
|
24
|
-
? `[
|
|
25
|
-
: `[
|
|
24
|
+
? `[json compiler]:Mpx单次构建中只能存在一个App,当前组件/页面[${module.resource}]通过[${issuer.resource}]非法引入,引用的资源将被忽略,请确保组件/页面资源通过usingComponents/pages配置引入!`
|
|
25
|
+
: `[json compiler]:Mpx单次构建中只能存在一个App,请检查当前entry中的资源[${module.resource}]是否为组件/页面,通过添加?component/page查询字符串显式声明该资源是组件/页面!`)
|
|
26
26
|
return callback(err)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ class ResolveDependency extends NullDependency {
|
|
|
36
36
|
const resolveResult = pagesMap[resourcePath] || currentComponentsMap[resourcePath] || mainComponentsMap[resourcePath] || currentStaticResourcesMap[resourcePath] || mainStaticResourcesMap[resourcePath] || ''
|
|
37
37
|
if (!resolveResult) {
|
|
38
38
|
if (!partialCompileRules || matchCondition(resourcePath, partialCompileRules)) {
|
|
39
|
-
compilation.errors.push(new Error(`
|
|
39
|
+
compilation.errors.push(new Error(`Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return resolveResult
|
package/lib/file-loader.js
CHANGED
|
@@ -8,9 +8,7 @@ module.exports = function loader (content, prevOptions) {
|
|
|
8
8
|
const options = prevOptions || loaderUtils.getOptions(this) || {}
|
|
9
9
|
const context = options.context || this.rootContext
|
|
10
10
|
const mpx = this.getMpx()
|
|
11
|
-
|
|
12
|
-
const { mode } = mpx
|
|
13
|
-
const isRN = ['ios', 'android', 'harmony'].includes(mode)
|
|
11
|
+
const isRN = ['ios', 'android', 'harmony'].includes(mpx.mode)
|
|
14
12
|
|
|
15
13
|
let url = loaderUtils.interpolateName(this, options.name, {
|
|
16
14
|
context,
|
|
@@ -19,7 +17,6 @@ module.exports = function loader (content, prevOptions) {
|
|
|
19
17
|
})
|
|
20
18
|
|
|
21
19
|
let outputPath = url
|
|
22
|
-
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
23
20
|
|
|
24
21
|
if (options.publicPath) {
|
|
25
22
|
if (options.outputPathCDN) {
|
|
@@ -30,19 +27,13 @@ module.exports = function loader (content, prevOptions) {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
} else {
|
|
30
|
+
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
33
31
|
const packageRoot = queryObj.packageRoot || ''
|
|
34
32
|
url = outputPath = toPosix(path.join(packageRoot, outputPath))
|
|
35
33
|
this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'staticResource', outputPath, packageRoot))
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
let publicPath
|
|
39
|
-
|
|
40
|
-
// 快手小程序 tabbar icon 资源路径不能以 / 开头
|
|
41
|
-
if (queryObj.from === 'tabbar' && mode === 'ks') {
|
|
42
|
-
publicPath = JSON.stringify(url)
|
|
43
|
-
} else {
|
|
44
|
-
publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`
|
|
45
|
-
}
|
|
36
|
+
let publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`
|
|
46
37
|
|
|
47
38
|
if (isRN) {
|
|
48
39
|
publicPath = `__mpx_require_external__(${JSON.stringify(url)})`
|
|
@@ -56,7 +47,6 @@ module.exports = function loader (content, prevOptions) {
|
|
|
56
47
|
? options.publicPath
|
|
57
48
|
: `${options.publicPath}/`}${url}`
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
publicPath = JSON.stringify(publicPath)
|
|
61
51
|
}
|
|
62
52
|
|
package/lib/helpers.js
CHANGED
|
@@ -69,8 +69,6 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
69
69
|
if (part.useJSONJS) options.useJSONJS = true
|
|
70
70
|
// eslint-disable-next-line no-fallthrough
|
|
71
71
|
case 'styles':
|
|
72
|
-
options.lang = part.lang
|
|
73
|
-
// eslint-disable-next-line no-fallthrough
|
|
74
72
|
case 'template':
|
|
75
73
|
options.extract = true
|
|
76
74
|
}
|
package/lib/index.js
CHANGED
|
@@ -36,7 +36,6 @@ const FixDescriptionInfoPlugin = require('./resolver/FixDescriptionInfoPlugin')
|
|
|
36
36
|
const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
37
37
|
const RecordPageConfigMapDependency = require('./dependencies/RecordPageConfigsMapDependency')
|
|
38
38
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
39
|
-
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
40
39
|
const RecordGlobalComponentsDependency = require('./dependencies/RecordGlobalComponentsDependency')
|
|
41
40
|
const RecordIndependentDependency = require('./dependencies/RecordIndependentDependency')
|
|
42
41
|
const DynamicEntryDependency = require('./dependencies/DynamicEntryDependency')
|
|
@@ -674,9 +673,6 @@ class MpxWebpackPlugin {
|
|
|
674
673
|
compilation.dependencyFactories.set(RecordResourceMapDependency, new NullFactory())
|
|
675
674
|
compilation.dependencyTemplates.set(RecordResourceMapDependency, new RecordResourceMapDependency.Template())
|
|
676
675
|
|
|
677
|
-
compilation.dependencyFactories.set(RecordModuleIdMapDependency, new NullFactory())
|
|
678
|
-
compilation.dependencyTemplates.set(RecordModuleIdMapDependency, new RecordModuleIdMapDependency.Template())
|
|
679
|
-
|
|
680
676
|
compilation.dependencyFactories.set(RecordGlobalComponentsDependency, new NullFactory())
|
|
681
677
|
compilation.dependencyTemplates.set(RecordGlobalComponentsDependency, new RecordGlobalComponentsDependency.Template())
|
|
682
678
|
|
|
@@ -725,8 +721,6 @@ class MpxWebpackPlugin {
|
|
|
725
721
|
componentsMap: {
|
|
726
722
|
main: {}
|
|
727
723
|
},
|
|
728
|
-
// 资源与moduleId关系记录
|
|
729
|
-
resourceModuleIdMap: {},
|
|
730
724
|
// 静态资源(图片,字体,独立样式)等,依照所属包进行记录
|
|
731
725
|
staticResourcesMap: {
|
|
732
726
|
main: {}
|
|
@@ -1690,12 +1684,11 @@ class MpxWebpackPlugin {
|
|
|
1690
1684
|
|
|
1691
1685
|
if (this.options.generateBuildMap) {
|
|
1692
1686
|
const pagesMap = compilation.__mpx__.pagesMap
|
|
1693
|
-
const resourceModuleIdMap = compilation.__mpx__.resourceModuleIdMap
|
|
1694
1687
|
const componentsPackageMap = compilation.__mpx__.componentsMap
|
|
1695
1688
|
const componentsMap = Object.keys(componentsPackageMap).map(item => componentsPackageMap[item]).reduce((pre, cur) => {
|
|
1696
1689
|
return { ...pre, ...cur }
|
|
1697
1690
|
}, {})
|
|
1698
|
-
const outputMap = JSON.stringify({
|
|
1691
|
+
const outputMap = JSON.stringify({ ...pagesMap, ...componentsMap })
|
|
1699
1692
|
const filename = this.options.generateBuildMap.filename || 'outputMap.json'
|
|
1700
1693
|
compilation.assets[filename] = new RawSource(outputMap)
|
|
1701
1694
|
}
|
|
@@ -1907,41 +1900,24 @@ try {
|
|
|
1907
1900
|
normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
|
|
1908
1901
|
const { queryObj } = parseRequest(createData.request)
|
|
1909
1902
|
const loaders = createData.loaders
|
|
1910
|
-
|
|
1911
|
-
// 样式 loader 类型检测和条件编译 loader 插入的工具函数
|
|
1912
|
-
const STYLE_LOADER_TYPES = ['stylus-loader', 'sass-loader', 'less-loader', 'css-loader', wxssLoaderPath]
|
|
1913
|
-
const injectStyleStripLoader = (loaders) => {
|
|
1914
|
-
// 检查是否已经存在 stripLoader
|
|
1915
|
-
const hasStripLoader = loaders.some(loader => {
|
|
1916
|
-
const loaderPath = toPosix(loader.loader)
|
|
1917
|
-
return loaderPath.includes('style-compiler/strip-conditional-loader')
|
|
1918
|
-
})
|
|
1919
|
-
if (hasStripLoader) {
|
|
1920
|
-
return
|
|
1921
|
-
}
|
|
1922
|
-
const loaderTypes = new Map(STYLE_LOADER_TYPES.map(type => [`node_modules/${type}`, -1]))
|
|
1923
|
-
loaders.forEach((loader, index) => {
|
|
1924
|
-
const currentLoader = toPosix(loader.loader)
|
|
1925
|
-
for (const [key] of loaderTypes) {
|
|
1926
|
-
if (currentLoader.includes(key)) {
|
|
1927
|
-
loaderTypes.set(key, index)
|
|
1928
|
-
break
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
})
|
|
1932
|
-
const targetIndex = STYLE_LOADER_TYPES
|
|
1933
|
-
.map(type => loaderTypes.get(`node_modules/${type}`))
|
|
1934
|
-
.find(index => index !== -1)
|
|
1935
|
-
|
|
1936
|
-
if (targetIndex !== undefined) {
|
|
1937
|
-
loaders.splice(targetIndex + 1, 0, { loader: styleStripConditionalPath })
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
1903
|
if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
|
|
1941
1904
|
const type = queryObj.type
|
|
1942
1905
|
const extract = queryObj.extract
|
|
1906
|
+
|
|
1943
1907
|
if (type === 'styles') {
|
|
1944
|
-
|
|
1908
|
+
let insertBeforeIndex = -1
|
|
1909
|
+
// 单次遍历收集所有索引
|
|
1910
|
+
loaders.forEach((loader, index) => {
|
|
1911
|
+
const currentLoader = toPosix(loader.loader)
|
|
1912
|
+
if (currentLoader.includes('node_modules/stylus-loader') || currentLoader.includes('node_modules/sass-loader') || currentLoader.includes('node_modules/less-loader')) {
|
|
1913
|
+
insertBeforeIndex = index
|
|
1914
|
+
}
|
|
1915
|
+
})
|
|
1916
|
+
|
|
1917
|
+
if (insertBeforeIndex !== -1) {
|
|
1918
|
+
loaders.splice(insertBeforeIndex, 0, { loader: styleStripConditionalPath })
|
|
1919
|
+
}
|
|
1920
|
+
loaders.push({ loader: styleStripConditionalPath })
|
|
1945
1921
|
}
|
|
1946
1922
|
|
|
1947
1923
|
switch (type) {
|
|
@@ -1995,7 +1971,6 @@ try {
|
|
|
1995
1971
|
}
|
|
1996
1972
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
1997
1973
|
if (isWeb(mpx.mode) && queryObj.mpxStyleOptions) {
|
|
1998
|
-
injectStyleStripLoader(loaders)
|
|
1999
1974
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
2000
1975
|
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
2001
1976
|
let cssLoaderIndex = -1
|
|
@@ -8,10 +8,8 @@ const loaderUtils = require('loader-utils')
|
|
|
8
8
|
const resolve = require('../utils/resolve')
|
|
9
9
|
const { matchCondition } = require('../utils/match-condition')
|
|
10
10
|
const { isWeb, isReact } = require('../utils/env')
|
|
11
|
-
const getBuildInTagComponent = require('../utils/get-build-tag-component')
|
|
12
|
-
const { capitalToHyphen } = require('../utils/string')
|
|
13
11
|
|
|
14
|
-
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry
|
|
12
|
+
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
|
|
15
13
|
const mpx = loaderContext.getMpx()
|
|
16
14
|
const resolveMode = mpx.resolveMode
|
|
17
15
|
const externals = mpx.externals
|
|
@@ -160,7 +158,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
160
158
|
const { resourcePath } = parseRequest(resource)
|
|
161
159
|
const relative = path.relative(context, resourcePath)
|
|
162
160
|
if (/^\./.test(relative)) {
|
|
163
|
-
return callback(new Error(`
|
|
161
|
+
return callback(new Error(`The js export path ${resourcePath} must be in the context ${context}!`))
|
|
164
162
|
}
|
|
165
163
|
const outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
166
164
|
const entry = getDynamicEntry(resource, 'export', outputPath, tarRoot, publicPath + tarRoot)
|
|
@@ -168,79 +166,11 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
168
166
|
})
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
const fillInComponentPlaceholder = ({ jsonObj, name: componentName, placeholder, placeholderEntry, resolveResourcePathMap }, callback) => {
|
|
172
|
-
let placeholderComponentName = placeholder.name
|
|
173
|
-
const componentPlaceholder = jsonObj.componentPlaceholder || {}
|
|
174
|
-
if (componentPlaceholder[componentName]) {
|
|
175
|
-
callback()
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
jsonObj.componentPlaceholder = componentPlaceholder
|
|
179
|
-
if (placeholderEntry) {
|
|
180
|
-
if (resolveResourcePathMap.has(placeholderComponentName) && resolveResourcePathMap.get(placeholderComponentName) !== placeholder.resourcePath) {
|
|
181
|
-
// 如果存在placeholder与已有usingComponents冲突, 重新生成一个组件名,在当前组件后增加一个数字
|
|
182
|
-
let i = 1
|
|
183
|
-
let newPlaceholder = placeholderComponentName + i
|
|
184
|
-
while (jsonObj.usingComponents[newPlaceholder]) {
|
|
185
|
-
newPlaceholder = placeholderComponentName + ++i
|
|
186
|
-
}
|
|
187
|
-
placeholderComponentName = newPlaceholder
|
|
188
|
-
}
|
|
189
|
-
jsonObj.usingComponents[placeholderComponentName] = placeholderEntry
|
|
190
|
-
resolveResourcePathMap.set(placeholderComponentName, placeholder.resourcePath)
|
|
191
|
-
}
|
|
192
|
-
componentPlaceholder[componentName] = placeholderComponentName
|
|
193
|
-
callback(null, {
|
|
194
|
-
name: placeholderComponentName,
|
|
195
|
-
entry: placeholderEntry
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const getNormalizePlaceholder = (placeholder) => {
|
|
200
|
-
if (typeof placeholder === 'string') {
|
|
201
|
-
placeholder = getBuildInTagComponent(mode, placeholder) || { name: placeholder }
|
|
202
|
-
}
|
|
203
|
-
if (!placeholder.name) {
|
|
204
|
-
emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
|
|
205
|
-
}
|
|
206
|
-
// ali 下与 rulesRunner 规则一致,组件名驼峰转连字符
|
|
207
|
-
if (mode === 'ali') {
|
|
208
|
-
placeholder.name = capitalToHyphen(placeholder.name)
|
|
209
|
-
}
|
|
210
|
-
return placeholder
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const processPlaceholder = ({ jsonObj, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, callback) => {
|
|
214
|
-
if (tarRoot) {
|
|
215
|
-
if (placeholder) {
|
|
216
|
-
placeholder = getNormalizePlaceholder(placeholder)
|
|
217
|
-
if (placeholder.resource) {
|
|
218
|
-
processComponent(placeholder.resource, context, { relativePath }, (err, entry, { resourcePath }) => {
|
|
219
|
-
if (err) return callback(err)
|
|
220
|
-
placeholder.resourcePath = resourcePath
|
|
221
|
-
fillInComponentPlaceholder({ jsonObj, name, placeholder, placeholderEntry: entry, resolveResourcePathMap }, callback)
|
|
222
|
-
})
|
|
223
|
-
} else {
|
|
224
|
-
fillInComponentPlaceholder({ jsonObj, name, placeholder }, callback)
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
if (!jsonObj.componentPlaceholder || !jsonObj.componentPlaceholder[name]) {
|
|
228
|
-
const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
|
|
229
|
-
emitError(errMsg)
|
|
230
|
-
}
|
|
231
|
-
callback()
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
callback()
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
169
|
return {
|
|
239
170
|
processComponent,
|
|
240
171
|
processDynamicEntry,
|
|
241
172
|
processPage,
|
|
242
173
|
processJsExport,
|
|
243
|
-
processPlaceholder,
|
|
244
174
|
isUrlRequest,
|
|
245
175
|
urlToRequest
|
|
246
176
|
}
|
|
@@ -15,6 +15,9 @@ const RecordRuntimeInfoDependency = require('../dependencies/RecordRuntimeInfoDe
|
|
|
15
15
|
const { MPX_DISABLE_EXTRACTOR_CACHE, RESOLVE_IGNORED_ERR, JSON_JS_EXT } = require('../utils/const')
|
|
16
16
|
const resolve = require('../utils/resolve')
|
|
17
17
|
const resolveTabBarPath = require('../utils/resolve-tab-bar-path')
|
|
18
|
+
const normalize = require('../utils/normalize')
|
|
19
|
+
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
20
|
+
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
18
21
|
const resolveMpxCustomElementPath = require('../utils/resolve-mpx-custom-element-path')
|
|
19
22
|
|
|
20
23
|
module.exports = function (content) {
|
|
@@ -40,6 +43,7 @@ module.exports = function (content) {
|
|
|
40
43
|
const globalSrcMode = mpx.srcMode
|
|
41
44
|
const localSrcMode = queryObj.mode
|
|
42
45
|
const srcMode = localSrcMode || globalSrcMode
|
|
46
|
+
const projectRoot = mpx.projectRoot
|
|
43
47
|
|
|
44
48
|
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
45
49
|
const publicPath = this._compilation.outputOptions.publicPath || ''
|
|
@@ -48,24 +52,46 @@ module.exports = function (content) {
|
|
|
48
52
|
|
|
49
53
|
const emitWarning = (msg) => {
|
|
50
54
|
this.emitWarning(
|
|
51
|
-
new Error('[
|
|
55
|
+
new Error('[json compiler][' + this.resource + ']: ' + msg)
|
|
52
56
|
)
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
const emitError = (msg) => {
|
|
56
60
|
this.emitError(
|
|
57
|
-
new Error('[
|
|
61
|
+
new Error('[json compiler][' + this.resource + ']: ' + msg)
|
|
58
62
|
)
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
const fillInComponentPlaceholder = (name, placeholder, placeholderEntry) => {
|
|
66
|
+
const componentPlaceholder = json.componentPlaceholder || {}
|
|
67
|
+
if (componentPlaceholder[name]) return
|
|
68
|
+
componentPlaceholder[name] = placeholder
|
|
69
|
+
json.componentPlaceholder = componentPlaceholder
|
|
70
|
+
if (placeholderEntry && !json.usingComponents[placeholder]) json.usingComponents[placeholder] = placeholderEntry
|
|
71
|
+
}
|
|
72
|
+
const normalizePlaceholder = (placeholder) => {
|
|
73
|
+
if (typeof placeholder === 'string') {
|
|
74
|
+
const placeholderMap = mode === 'ali'
|
|
75
|
+
? {
|
|
76
|
+
view: { name: 'mpx-view', resource: mpxViewPath },
|
|
77
|
+
text: { name: 'mpx-text', resource: mpxTextPath }
|
|
78
|
+
}
|
|
79
|
+
: {}
|
|
80
|
+
placeholder = placeholderMap[placeholder] || { name: placeholder }
|
|
81
|
+
}
|
|
82
|
+
if (!placeholder.name) {
|
|
83
|
+
emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
|
|
84
|
+
}
|
|
85
|
+
return placeholder
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
const {
|
|
62
89
|
isUrlRequest,
|
|
63
90
|
urlToRequest,
|
|
64
91
|
processPage,
|
|
65
92
|
processDynamicEntry,
|
|
66
93
|
processComponent,
|
|
67
|
-
processJsExport
|
|
68
|
-
processPlaceholder
|
|
94
|
+
processJsExport
|
|
69
95
|
} = createJSONHelper({
|
|
70
96
|
loaderContext: this,
|
|
71
97
|
emitWarning,
|
|
@@ -197,9 +223,6 @@ module.exports = function (content) {
|
|
|
197
223
|
|
|
198
224
|
const processComponents = (components, context, callback) => {
|
|
199
225
|
if (components) {
|
|
200
|
-
// 存在所有命中asyncSubpackageRules的组件
|
|
201
|
-
const asyncComponents = []
|
|
202
|
-
const resolveResourcePathMap = new Map()
|
|
203
226
|
async.eachOf(components, (component, name, callback) => {
|
|
204
227
|
processComponent(component, context, { relativePath }, (err, entry, { tarRoot, placeholder, resourcePath, queryObj = {} } = {}) => {
|
|
205
228
|
if (err === RESOLVE_IGNORED_ERR) {
|
|
@@ -219,9 +242,29 @@ module.exports = function (content) {
|
|
|
219
242
|
isDynamic: queryObj.isDynamic
|
|
220
243
|
}
|
|
221
244
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
245
|
+
if (tarRoot) {
|
|
246
|
+
if (placeholder) {
|
|
247
|
+
placeholder = normalizePlaceholder(placeholder)
|
|
248
|
+
if (placeholder.resource) {
|
|
249
|
+
processComponent(placeholder.resource, projectRoot, { relativePath }, (err, entry) => {
|
|
250
|
+
if (err) return callback(err)
|
|
251
|
+
fillInComponentPlaceholder(name, placeholder.name, entry)
|
|
252
|
+
callback()
|
|
253
|
+
})
|
|
254
|
+
} else {
|
|
255
|
+
fillInComponentPlaceholder(name, placeholder.name)
|
|
256
|
+
callback()
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
if (!json.componentPlaceholder || !json.componentPlaceholder[name]) {
|
|
260
|
+
const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
|
|
261
|
+
emitError(errMsg)
|
|
262
|
+
}
|
|
263
|
+
callback()
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
callback()
|
|
267
|
+
}
|
|
225
268
|
})
|
|
226
269
|
}, (err) => {
|
|
227
270
|
if (err) return callback(err)
|
|
@@ -236,10 +279,7 @@ module.exports = function (content) {
|
|
|
236
279
|
components.element = mpxCustomElementPath
|
|
237
280
|
Object.assign(components, mpx.getPackageInjectedComponentsMap(packageName))
|
|
238
281
|
}
|
|
239
|
-
|
|
240
|
-
async.each(asyncComponents, ({ name, tarRoot, placeholder, relativePath }, callback) => {
|
|
241
|
-
processPlaceholder({ jsonObj: json, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, callback)
|
|
242
|
-
}, callback)
|
|
282
|
+
callback()
|
|
243
283
|
})
|
|
244
284
|
} else {
|
|
245
285
|
callback()
|
|
@@ -481,10 +521,10 @@ module.exports = function (content) {
|
|
|
481
521
|
if (json.tabBar && json.tabBar[itemKey]) {
|
|
482
522
|
json.tabBar[itemKey].forEach((item, index) => {
|
|
483
523
|
if (item[iconKey] && isUrlRequest(item[iconKey])) {
|
|
484
|
-
output += `json.tabBar.${itemKey}[${index}].${iconKey} = require("${addQuery(urlToRequest(item[iconKey]), { useLocal: true
|
|
524
|
+
output += `json.tabBar.${itemKey}[${index}].${iconKey} = require("${addQuery(urlToRequest(item[iconKey]), { useLocal: true })}");\n`
|
|
485
525
|
}
|
|
486
526
|
if (item[activeIconKey] && isUrlRequest(item[activeIconKey])) {
|
|
487
|
-
output += `json.tabBar.${itemKey}[${index}].${activeIconKey} = require("${addQuery(urlToRequest(item[activeIconKey]), { useLocal: true
|
|
527
|
+
output += `json.tabBar.${itemKey}[${index}].${activeIconKey} = require("${addQuery(urlToRequest(item[activeIconKey]), { useLocal: true })}");\n`
|
|
488
528
|
}
|
|
489
529
|
})
|
|
490
530
|
}
|
|
@@ -23,13 +23,13 @@ module.exports = function (source) {
|
|
|
23
23
|
|
|
24
24
|
const emitWarning = (msg) => {
|
|
25
25
|
this.emitWarning(
|
|
26
|
-
new Error('[
|
|
26
|
+
new Error('[plugin loader][' + this.resource + ']: ' + msg)
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const emitError = (msg) => {
|
|
31
31
|
this.emitError(
|
|
32
|
-
new Error('[
|
|
32
|
+
new Error('[plugin loader][' + this.resource + ']: ' + msg)
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
package/lib/loader.js
CHANGED
|
@@ -10,7 +10,6 @@ const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
|
10
10
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
11
11
|
const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDependency')
|
|
12
12
|
const DynamicEntryDependency = require('./dependencies/DynamicEntryDependency')
|
|
13
|
-
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
14
13
|
const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
|
|
15
14
|
const { isReact } = require('./utils/env')
|
|
16
15
|
const preProcessJson = require('./utils/pre-process-json')
|
|
@@ -51,13 +50,13 @@ module.exports = function (content) {
|
|
|
51
50
|
|
|
52
51
|
const emitWarning = (msg) => {
|
|
53
52
|
this.emitWarning(
|
|
54
|
-
new Error('[
|
|
53
|
+
new Error('[mpx-loader][' + this.resource + ']: ' + msg)
|
|
55
54
|
)
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
const emitError = (msg) => {
|
|
59
58
|
this.emitError(
|
|
60
|
-
new Error('[
|
|
59
|
+
new Error('[mpx-loader][' + this.resource + ']: ' + msg)
|
|
61
60
|
)
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -88,7 +87,6 @@ module.exports = function (content) {
|
|
|
88
87
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
89
88
|
const filePath = this.resourcePath
|
|
90
89
|
const moduleId = mpx.getModuleId(resourcePath, ctorType === 'app')
|
|
91
|
-
this._module.addPresentationalDependency(new RecordModuleIdMapDependency(moduleId, resourcePath))
|
|
92
90
|
|
|
93
91
|
const parts = parseComponent(content, {
|
|
94
92
|
filePath,
|
|
@@ -123,7 +121,6 @@ module.exports = function (content) {
|
|
|
123
121
|
componentPlaceholder,
|
|
124
122
|
componentGenerics,
|
|
125
123
|
usingComponentsInfo,
|
|
126
|
-
originalUsingComponents,
|
|
127
124
|
jsonContent
|
|
128
125
|
} = jsonInfo
|
|
129
126
|
const hasScoped = parts.styles.some(({ scoped }) => scoped) || autoScope
|
|
@@ -147,8 +144,7 @@ module.exports = function (content) {
|
|
|
147
144
|
hasScoped,
|
|
148
145
|
hasComment,
|
|
149
146
|
isNative,
|
|
150
|
-
usingComponentsInfo,
|
|
151
|
-
originalUsingComponents,
|
|
147
|
+
usingComponentsInfo: JSON.stringify(usingComponentsInfo),
|
|
152
148
|
componentGenerics,
|
|
153
149
|
autoScope,
|
|
154
150
|
callback
|
|
@@ -170,8 +166,7 @@ module.exports = function (content) {
|
|
|
170
166
|
hasScoped,
|
|
171
167
|
hasComment,
|
|
172
168
|
isNative,
|
|
173
|
-
usingComponentsInfo,
|
|
174
|
-
originalUsingComponents,
|
|
169
|
+
usingComponentsInfo: JSON.stringify(usingComponentsInfo),
|
|
175
170
|
componentGenerics,
|
|
176
171
|
autoScope,
|
|
177
172
|
callback
|
|
@@ -240,7 +235,6 @@ module.exports = function (content) {
|
|
|
240
235
|
ctorType,
|
|
241
236
|
moduleId,
|
|
242
237
|
usingComponentsInfo: JSON.stringify(usingComponentsInfo),
|
|
243
|
-
originalUsingComponents: JSON.stringify(originalUsingComponents),
|
|
244
238
|
componentPlaceholder
|
|
245
239
|
// 添加babel处理渲染函数中可能包含的...展开运算符
|
|
246
240
|
// 由于...运算符应用范围极小以及babel成本极高,先关闭此特性后续看情况打开
|
package/lib/native-loader.js
CHANGED
|
@@ -8,7 +8,6 @@ const { JSON_JS_EXT } = require('./utils/const')
|
|
|
8
8
|
const getEntryName = require('./utils/get-entry-name')
|
|
9
9
|
const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
10
10
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
11
|
-
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
12
11
|
const preProcessJson = require('./utils/pre-process-json')
|
|
13
12
|
|
|
14
13
|
// todo native-loader考虑与mpx-loader或加强复用,原生组件约等于4个区块都为src的.mpx文件
|
|
@@ -24,9 +23,7 @@ module.exports = function (content) {
|
|
|
24
23
|
const loaderContext = this
|
|
25
24
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
26
25
|
const filePath = this.resourcePath
|
|
27
|
-
const moduleId = mpx.getModuleId(filePath
|
|
28
|
-
this._module.addPresentationalDependency(new RecordModuleIdMapDependency(moduleId, filePath))
|
|
29
|
-
|
|
26
|
+
const moduleId = mpx.getModuleId(filePath)
|
|
30
27
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
31
28
|
const packageRoot = queryObj.packageRoot || mpx.currentPackageRoot
|
|
32
29
|
const mode = mpx.mode
|
|
@@ -107,13 +104,13 @@ module.exports = function (content) {
|
|
|
107
104
|
|
|
108
105
|
const emitWarning = (msg) => {
|
|
109
106
|
this.emitWarning(
|
|
110
|
-
new Error('[
|
|
107
|
+
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
111
108
|
)
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
const emitError = (msg) => {
|
|
115
112
|
this.emitError(
|
|
116
|
-
new Error('[
|
|
113
|
+
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
117
114
|
)
|
|
118
115
|
}
|
|
119
116
|
let ctorType = pagesMap[resourcePath]
|