@mpxjs/webpack-plugin 2.10.17 → 2.10.18-beta.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 +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +231 -0
- package/lib/index.js +70 -73
- package/lib/init.js +3 -0
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +102 -72
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +25 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +10 -0
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +19 -2
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/script-helper.js +2 -2
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +17 -7
- package/lib/resolver/ExtendComponentsPlugin.js +60 -0
- package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
- package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
- package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
- package/lib/runtime/components/react/dist/context.d.ts +10 -3
- package/lib/runtime/components/react/dist/context.js +1 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +66 -50
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +48 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +292 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +136 -83
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +10 -9
- package/lib/runtime/components/react/dist/utils.jsx +47 -24
- package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +77 -54
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
- package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
- package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +156 -81
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +51 -27
- package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
- package/lib/runtime/components/web/mpx-section-list.vue +551 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
- package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
- package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +1 -2
- package/lib/style-compiler/strip-conditional.js +243 -0
- package/lib/template-compiler/compiler.js +9 -8
- package/lib/utils/const.js +29 -0
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/lib/wxss/loader.js +4 -1
- package/lib/wxss/utils.js +7 -2
- package/package.json +7 -14
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- 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/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
- package/lib/style-compiler/strip-conditional-loader.js +0 -289
package/lib/config.js
CHANGED
|
@@ -553,6 +553,66 @@ 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
|
+
},
|
|
556
616
|
ios: reactConfig,
|
|
557
617
|
android: reactConfig,
|
|
558
618
|
harmony: reactConfig
|
package/lib/file-loader.js
CHANGED
|
@@ -8,7 +8,9 @@ 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
|
-
|
|
11
|
+
|
|
12
|
+
const { mode } = mpx
|
|
13
|
+
const isRN = ['ios', 'android', 'harmony'].includes(mode)
|
|
12
14
|
|
|
13
15
|
let url = loaderUtils.interpolateName(this, options.name, {
|
|
14
16
|
context,
|
|
@@ -47,6 +49,7 @@ module.exports = function loader (content, prevOptions) {
|
|
|
47
49
|
? options.publicPath
|
|
48
50
|
: `${options.publicPath}/`}${url}`
|
|
49
51
|
}
|
|
52
|
+
|
|
50
53
|
publicPath = JSON.stringify(publicPath)
|
|
51
54
|
}
|
|
52
55
|
|
package/lib/global.d.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import * as webpack from 'webpack'
|
|
2
|
+
|
|
3
|
+
declare module 'webpack' {
|
|
4
|
+
interface Compilation {
|
|
5
|
+
__mpx__: MpxContext
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface Compiler {
|
|
9
|
+
__mpx__?: boolean
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
type MpxLoaderContext<T> = webpack.LoaderContext<T> & {
|
|
15
|
+
getMpx(): MpxContext
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface MpxContext {
|
|
19
|
+
/**
|
|
20
|
+
* 用于使用 webpack-virtual-modules 功能,目前仅在输出 web 时支持使用
|
|
21
|
+
*/
|
|
22
|
+
__vfs: any | null
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* app 信息,便于获取 appName
|
|
26
|
+
*/
|
|
27
|
+
appInfo: {
|
|
28
|
+
resourcePath?: string
|
|
29
|
+
name?: string
|
|
30
|
+
[key: string]: any
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* pageConfig 信息
|
|
35
|
+
*/
|
|
36
|
+
pageConfigsMap: Record<string, any>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* pages 全局记录,无需区分主包/分包
|
|
40
|
+
*/
|
|
41
|
+
pagesMap: Record<string, string>
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 组件资源记录,按所属包进行记录(如 componentsMap.main)
|
|
45
|
+
*/
|
|
46
|
+
componentsMap: Record<string, Record<string, string>>
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 静态资源(图片、字体、独立样式)等,按所属包进行记录
|
|
50
|
+
*/
|
|
51
|
+
staticResourcesMap: Record<string, Record<string, string>>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 用于记录命中 subpackageModulesRules 的 JS 模块分包归属,用于 JS 多分包冗余输出
|
|
55
|
+
*/
|
|
56
|
+
subpackageModulesMap: Record<string, Record<string, string>>
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 记录其他资源,如 pluginMain、pluginExport,无需区分主包/分包
|
|
60
|
+
*/
|
|
61
|
+
otherResourcesMap: Record<string, any>
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 记录独立分包
|
|
65
|
+
*/
|
|
66
|
+
independentSubpackagesMap: Record<string, any>
|
|
67
|
+
|
|
68
|
+
subpackagesEntriesMap: Record<string, any>
|
|
69
|
+
postSubpackageEntriesMap: Record<string, any>
|
|
70
|
+
replacePathMap: Record<string, string>
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 导出模块集合
|
|
74
|
+
*/
|
|
75
|
+
exportModules: Set<any>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 记录动态添加入口的分包信息
|
|
79
|
+
*/
|
|
80
|
+
dynamicEntryInfo: Record<string, any>
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 记录 entryModule 与 entryNode 的对应关系,用于体积分析
|
|
84
|
+
*/
|
|
85
|
+
entryNodeModulesMap: Map<any, any>
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 记录与 asset 相关联的 modules,用于体积分析
|
|
89
|
+
*/
|
|
90
|
+
assetsModulesMap: Map<string, Set<any>>
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 记录与 asset 相关联的 AST,用于体积分析和 esCheck,避免重复 parse
|
|
94
|
+
*/
|
|
95
|
+
assetsASTsMap: Map<string, any>
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 记录 RequireExternalDependency 相关资源路径
|
|
99
|
+
*/
|
|
100
|
+
externalRequestsMap: Map<string, any>
|
|
101
|
+
|
|
102
|
+
globalComponents: Record<string, any>
|
|
103
|
+
globalComponentsInfo: Record<string, any>
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* todo: es6 Map 读写性能高于 object,之后会逐步替换
|
|
107
|
+
*/
|
|
108
|
+
wxsAssetsCache: Map<string, any>
|
|
109
|
+
addEntryPromiseMap: Map<string, Promise<any>>
|
|
110
|
+
currentPackageRoot: string
|
|
111
|
+
wxsContentMap: Record<string, string>
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 是否强制使用页面构造函数
|
|
115
|
+
*/
|
|
116
|
+
forceUsePageCtor: boolean
|
|
117
|
+
|
|
118
|
+
resolveMode: string
|
|
119
|
+
mode: string
|
|
120
|
+
srcMode: string
|
|
121
|
+
env: string
|
|
122
|
+
externalClasses: string[]
|
|
123
|
+
projectRoot: string
|
|
124
|
+
autoScopeRules: any
|
|
125
|
+
autoVirtualHostRules: any
|
|
126
|
+
customTextRules: any
|
|
127
|
+
transRpxRules: any
|
|
128
|
+
postcssInlineConfig: any
|
|
129
|
+
decodeHTMLText: boolean
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* native 文件专用配置
|
|
133
|
+
*/
|
|
134
|
+
i18n: any | null
|
|
135
|
+
checkUsingComponentsRules: any
|
|
136
|
+
forceDisableBuiltInLoader: boolean
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 默认的应用标题
|
|
140
|
+
*/
|
|
141
|
+
appTitle: string
|
|
142
|
+
|
|
143
|
+
attributes: any[]
|
|
144
|
+
externals: any[]
|
|
145
|
+
useRelativePath: boolean
|
|
146
|
+
removedChunks: any[]
|
|
147
|
+
forceProxyEventRules: any
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 若配置 disableRequireAsync=true,则全平台构建不支持异步分包
|
|
151
|
+
*/
|
|
152
|
+
supportRequireAsync: boolean
|
|
153
|
+
partialCompileRules: any
|
|
154
|
+
asyncSubpackageRules: any[]
|
|
155
|
+
transSubpackageRules: any
|
|
156
|
+
optimizeRenderRules: any[]
|
|
157
|
+
|
|
158
|
+
addEntryModuleIssuer: (module: string, issuer: string) => void
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 资源路径的哈希函数(用于生成输出唯一名)
|
|
162
|
+
*/
|
|
163
|
+
pathHash: (resourcePath: string) => string
|
|
164
|
+
|
|
165
|
+
// 缓存与工具
|
|
166
|
+
loaderContentCache: Map<string, any>
|
|
167
|
+
extractedFilesCache: Map<string, string>
|
|
168
|
+
|
|
169
|
+
// 函数接口
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 收集动态入口信息(分包、文件名、是否为页面、是否包含异步等)
|
|
173
|
+
*/
|
|
174
|
+
collectDynamicEntryInfo: (info: { resource: string; packageName: string; filename: string; entryType: string; hasAsync: boolean }) => void
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 添加入口(包装了 webpack 的 addEntry)
|
|
178
|
+
*/
|
|
179
|
+
addEntry: (request: string, name: string, callback: (err?: Error, result?: any) => void) => any
|
|
180
|
+
|
|
181
|
+
getModuleId: (filePath: string, isApp?: boolean) => string
|
|
182
|
+
getEntryNode: (module: any, type?: string) => any
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 根据资源路径和类型返回输出路径(支持自定义输出、冲突处理等)
|
|
186
|
+
*/
|
|
187
|
+
getOutputPath: (resourcePath: string, type: string, opts?: { ext?: string; conflictPath?: string }) => string
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 获取提取后的文件名(支持静态、插件、普通资源)
|
|
191
|
+
*/
|
|
192
|
+
getExtractedFile: (resource: string, opts?: { error?: (err: Error) => void }) => string
|
|
193
|
+
|
|
194
|
+
recordResourceMap: (params: {
|
|
195
|
+
resourcePath: string
|
|
196
|
+
resourceType: string
|
|
197
|
+
outputPath?: string
|
|
198
|
+
packageRoot?: string
|
|
199
|
+
recordOnly?: boolean
|
|
200
|
+
warn?: (e: Error) => void
|
|
201
|
+
error?: (e: Error) => void
|
|
202
|
+
}) => { outputPath?: string; alreadyOutputted?: boolean }
|
|
203
|
+
|
|
204
|
+
getPackageInfo: (params: {
|
|
205
|
+
resource: string
|
|
206
|
+
resourceType: string
|
|
207
|
+
outputPath?: string
|
|
208
|
+
issuerResource?: string
|
|
209
|
+
warn?: (e: Error) => void
|
|
210
|
+
error?: (e: Error) => void
|
|
211
|
+
}) => { packageName: string; packageRoot: string; outputPath?: string; alreadyOutputted?: boolean }
|
|
212
|
+
|
|
213
|
+
// 运行时信息与注入相关
|
|
214
|
+
runtimeInfo: Record<string, any>
|
|
215
|
+
dynamicSlotDependencies: Record<string, any>
|
|
216
|
+
dynamicTemplateRuleRunner: any
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 依据 package 注入到 mpx-custom-element-*.json 里面的组件路径
|
|
220
|
+
*/
|
|
221
|
+
getPackageInjectedComponentsMap: (packageName?: string) => Record<string, string>
|
|
222
|
+
|
|
223
|
+
getPackageInjectedTemplateConfig: (packageName?: string) => any
|
|
224
|
+
injectDynamicSlotDependencies: (usingComponents: string, resourcePath: string) => string
|
|
225
|
+
changeHashNameForAstNode: (templateAst: string, componentsMap: any) => string
|
|
226
|
+
collectDynamicSlotDependencies: (packageName?: string) => void
|
|
227
|
+
|
|
228
|
+
// 其它任意扩展字段
|
|
229
|
+
[key: string]: any
|
|
230
|
+
}
|
|
231
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
require('./init')
|
|
3
4
|
const path = require('path')
|
|
4
5
|
const { ConcatSource, RawSource } = require('webpack').sources
|
|
5
6
|
const ResolveDependency = require('./dependencies/ResolveDependency')
|
|
@@ -29,6 +30,7 @@ const AddEnvPlugin = require('./resolver/AddEnvPlugin')
|
|
|
29
30
|
const PackageEntryPlugin = require('./resolver/PackageEntryPlugin')
|
|
30
31
|
const DynamicRuntimePlugin = require('./resolver/DynamicRuntimePlugin')
|
|
31
32
|
const FixDescriptionInfoPlugin = require('./resolver/FixDescriptionInfoPlugin')
|
|
33
|
+
const ExtendComponentsPlugin = require('./resolver/ExtendComponentsPlugin')
|
|
32
34
|
// const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency')
|
|
33
35
|
// const HarmonyImportSideEffectDependency = require('webpack/lib/dependencies/HarmonyImportSideEffectDependency')
|
|
34
36
|
// const RequireHeaderDependency = require('webpack/lib/dependencies/RequireHeaderDependency')
|
|
@@ -58,7 +60,6 @@ const wxssLoaderPath = normalize.lib('wxss/index')
|
|
|
58
60
|
const wxmlLoaderPath = normalize.lib('wxml/loader')
|
|
59
61
|
const wxsLoaderPath = normalize.lib('wxs/loader')
|
|
60
62
|
const styleCompilerPath = normalize.lib('style-compiler/index')
|
|
61
|
-
const styleStripConditionalPath = normalize.lib('style-compiler/strip-conditional-loader')
|
|
62
63
|
const templateCompilerPath = normalize.lib('template-compiler/index')
|
|
63
64
|
const jsonCompilerPath = normalize.lib('json-compiler/index')
|
|
64
65
|
const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
|
|
@@ -79,13 +80,17 @@ const LoadAsyncChunkModule = require('./react/LoadAsyncChunkModule')
|
|
|
79
80
|
const ExternalModule = require('webpack/lib/ExternalModule')
|
|
80
81
|
const { RetryRuntimeModule, RetryRuntimeGlobal } = require('./dependencies/RetryRuntimeModule')
|
|
81
82
|
const checkVersionCompatibility = require('./utils/check-core-version-match')
|
|
82
|
-
|
|
83
|
+
const { startFSStripForCss, registerStripCompilation } = require('./style-compiler/strip-conditional')
|
|
83
84
|
checkVersionCompatibility()
|
|
84
85
|
|
|
85
86
|
const isProductionLikeMode = options => {
|
|
86
87
|
return options.mode === 'production' || !options.mode
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @param {import('webpack').NormalModule} module
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
89
94
|
const isStaticModule = module => {
|
|
90
95
|
if (!module.resource) return false
|
|
91
96
|
const { queryObj } = parseRequest(module.resource)
|
|
@@ -322,7 +327,13 @@ class MpxWebpackPlugin {
|
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
329
|
|
|
330
|
+
/**
|
|
331
|
+
* @param {import('webpack').Compiler} compiler
|
|
332
|
+
*/
|
|
325
333
|
apply (compiler) {
|
|
334
|
+
// 注入 fs 代理
|
|
335
|
+
startFSStripForCss(this.options.defs)
|
|
336
|
+
|
|
326
337
|
if (!compiler.__mpx__) {
|
|
327
338
|
compiler.__mpx__ = true
|
|
328
339
|
} else {
|
|
@@ -393,6 +404,7 @@ class MpxWebpackPlugin {
|
|
|
393
404
|
const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
|
|
394
405
|
const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, this.options.normalNpmPackages, 'file')
|
|
395
406
|
const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
|
|
407
|
+
const extendComponentsPlugin = new ExtendComponentsPlugin('described-resolve', this.options.mode, 'resolve')
|
|
396
408
|
|
|
397
409
|
if (Array.isArray(compiler.options.resolve.plugins)) {
|
|
398
410
|
compiler.options.resolve.plugins.push(addModePlugin)
|
|
@@ -407,6 +419,7 @@ class MpxWebpackPlugin {
|
|
|
407
419
|
}
|
|
408
420
|
compiler.options.resolve.plugins.push(packageEntryPlugin)
|
|
409
421
|
compiler.options.resolve.plugins.push(new FixDescriptionInfoPlugin())
|
|
422
|
+
compiler.options.resolve.plugins.push(extendComponentsPlugin)
|
|
410
423
|
compiler.options.resolve.plugins.push(dynamicPlugin)
|
|
411
424
|
|
|
412
425
|
const optimization = compiler.options.optimization
|
|
@@ -706,6 +719,7 @@ class MpxWebpackPlugin {
|
|
|
706
719
|
})
|
|
707
720
|
|
|
708
721
|
compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
|
|
722
|
+
registerStripCompilation(compilation)
|
|
709
723
|
compilation.warnings.push(...warnings)
|
|
710
724
|
compilation.errors.push(...errors)
|
|
711
725
|
const moduleGraph = compilation.moduleGraph
|
|
@@ -1444,6 +1458,7 @@ class MpxWebpackPlugin {
|
|
|
1444
1458
|
const context = parser.state.module.context
|
|
1445
1459
|
const { queryObj, resourcePath } = parseRequest(request)
|
|
1446
1460
|
let tarRoot = queryObj.root
|
|
1461
|
+
|
|
1447
1462
|
if (!tarRoot && mpx.asyncSubpackageRules) {
|
|
1448
1463
|
for (const item of mpx.asyncSubpackageRules) {
|
|
1449
1464
|
if (matchCondition(resourcePath, item)) {
|
|
@@ -1452,49 +1467,49 @@ class MpxWebpackPlugin {
|
|
|
1452
1467
|
}
|
|
1453
1468
|
}
|
|
1454
1469
|
}
|
|
1455
|
-
|
|
1470
|
+
// TODO 后续考虑和 asyncSubpackageRules 配置合并
|
|
1471
|
+
if (isReact(mpx.mode)) tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
|
|
1472
|
+
|
|
1473
|
+
if (tarRoot && mpx.supportRequireAsync) {
|
|
1456
1474
|
// 删除root query
|
|
1457
1475
|
if (queryObj.root) request = addQuery(request, {}, false, ['root'])
|
|
1458
1476
|
// wx、ali和web平台支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
|
|
1459
|
-
if (mpx.
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
depBlock.addDependency(dep)
|
|
1475
|
-
parser.state.current.addBlock(depBlock)
|
|
1476
|
-
} else {
|
|
1477
|
-
const dep = new DynamicEntryDependency(range, request, 'export', '', tarRoot, '', context, {
|
|
1478
|
-
isAsync: true,
|
|
1479
|
-
isRequireAsync: true,
|
|
1480
|
-
retryRequireAsync: this.options.retryRequireAsync,
|
|
1481
|
-
requireAsyncRange: expr.range
|
|
1482
|
-
})
|
|
1483
|
-
|
|
1484
|
-
parser.state.current.addPresentationalDependency(dep)
|
|
1485
|
-
// 包含require.async的模块不能被concatenate,避免DynamicEntryDependency中无法获取模块chunk以计算相对路径
|
|
1486
|
-
parser.state.module.buildInfo.moduleConcatenationBailout = 'require async'
|
|
1487
|
-
}
|
|
1477
|
+
if (isWeb(mpx.mode) || isReact(mpx.mode)) {
|
|
1478
|
+
const depBlock = new AsyncDependenciesBlock(
|
|
1479
|
+
{
|
|
1480
|
+
name: tarRoot + '/index'
|
|
1481
|
+
},
|
|
1482
|
+
expr.loc,
|
|
1483
|
+
request
|
|
1484
|
+
)
|
|
1485
|
+
const dep = new ImportDependency(request, expr.range, undefined, {
|
|
1486
|
+
isRequireAsync: true,
|
|
1487
|
+
retryRequireAsync: this.options.retryRequireAsync
|
|
1488
|
+
})
|
|
1489
|
+
dep.loc = expr.loc
|
|
1490
|
+
depBlock.addDependency(dep)
|
|
1491
|
+
parser.state.current.addBlock(depBlock)
|
|
1488
1492
|
} else {
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1493
|
+
const dep = new DynamicEntryDependency(range, request, 'export', '', tarRoot, '', context, {
|
|
1494
|
+
isAsync: true,
|
|
1495
|
+
isRequireAsync: true,
|
|
1496
|
+
retryRequireAsync: this.options.retryRequireAsync,
|
|
1497
|
+
requireAsyncRange: expr.range
|
|
1498
|
+
})
|
|
1499
|
+
|
|
1500
|
+
parser.state.current.addPresentationalDependency(dep)
|
|
1501
|
+
// 包含require.async的模块不能被concatenate,避免DynamicEntryDependency中无法获取模块chunk以计算相对路径
|
|
1502
|
+
parser.state.module.buildInfo.moduleConcatenationBailout = 'require async'
|
|
1492
1503
|
}
|
|
1493
|
-
if (args) parser.walkExpressions(args)
|
|
1494
|
-
return true
|
|
1495
1504
|
} else {
|
|
1496
|
-
|
|
1505
|
+
const dep = new CommonJsAsyncDependency(request, expr.range)
|
|
1506
|
+
parser.state.current.addDependency(dep)
|
|
1507
|
+
if (!tarRoot) {
|
|
1508
|
+
compilation.warnings.push(new Error(`The require async JS [${request}] need to declare subpackage name by root`))
|
|
1509
|
+
}
|
|
1497
1510
|
}
|
|
1511
|
+
if (args) parser.walkExpressions(args)
|
|
1512
|
+
return true
|
|
1498
1513
|
}
|
|
1499
1514
|
}
|
|
1500
1515
|
|
|
@@ -1729,7 +1744,14 @@ class MpxWebpackPlugin {
|
|
|
1729
1744
|
|
|
1730
1745
|
if (isReact(mpx.mode)) {
|
|
1731
1746
|
// 添加 @refresh reset 注释用于在 React HMR 时刷新组件
|
|
1732
|
-
|
|
1747
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1748
|
+
source.add(`/* @refresh reset */
|
|
1749
|
+
if (module.hot) {
|
|
1750
|
+
module.hot.accept(() => {
|
|
1751
|
+
require("react-native").DevSettings.reload();
|
|
1752
|
+
});
|
|
1753
|
+
}\n`)
|
|
1754
|
+
}
|
|
1733
1755
|
// 注入页面的配置,供screen前置设置导航情况
|
|
1734
1756
|
if (isRuntime) {
|
|
1735
1757
|
source.add('// inject pageconfigmap for screen\n' +
|
|
@@ -1907,42 +1929,9 @@ try {
|
|
|
1907
1929
|
normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
|
|
1908
1930
|
const { queryObj } = parseRequest(createData.request)
|
|
1909
1931
|
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
1932
|
if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
|
|
1941
1933
|
const type = queryObj.type
|
|
1942
1934
|
const extract = queryObj.extract
|
|
1943
|
-
if (type === 'styles') {
|
|
1944
|
-
injectStyleStripLoader(loaders)
|
|
1945
|
-
}
|
|
1946
1935
|
|
|
1947
1936
|
switch (type) {
|
|
1948
1937
|
case 'styles':
|
|
@@ -1995,7 +1984,6 @@ try {
|
|
|
1995
1984
|
}
|
|
1996
1985
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
1997
1986
|
if (isWeb(mpx.mode) && queryObj.mpxStyleOptions) {
|
|
1998
|
-
injectStyleStripLoader(loaders)
|
|
1999
1987
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
2000
1988
|
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
2001
1989
|
let cssLoaderIndex = -1
|
|
@@ -2087,3 +2075,12 @@ try {
|
|
|
2087
2075
|
}
|
|
2088
2076
|
|
|
2089
2077
|
module.exports = MpxWebpackPlugin
|
|
2078
|
+
|
|
2079
|
+
/**
|
|
2080
|
+
* 定义 MpxWebpackPlugin 的配置
|
|
2081
|
+
* @param {MpxWebpackPluginOptions} options - 插件选项
|
|
2082
|
+
* @returns {MpxWebpackPluginOptions}
|
|
2083
|
+
*/
|
|
2084
|
+
module.exports.defineConfig = function defineConfig(options) {
|
|
2085
|
+
return options
|
|
2086
|
+
}
|
package/lib/init.js
ADDED
|
@@ -472,6 +472,11 @@ module.exports = function (content) {
|
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
const wrapTabBarAsset = (expr) => {
|
|
476
|
+
if (mode !== 'ks') return expr
|
|
477
|
+
return `(function(p){return typeof p === "string" && p.charAt(0) === "/" ? p.slice(1) : p})(${expr})`
|
|
478
|
+
}
|
|
479
|
+
|
|
475
480
|
const processTabBar = (output) => {
|
|
476
481
|
const tabBarCfg = config[mode].tabBar
|
|
477
482
|
const itemKey = tabBarCfg.itemKey
|
|
@@ -480,11 +485,15 @@ module.exports = function (content) {
|
|
|
480
485
|
|
|
481
486
|
if (json.tabBar && json.tabBar[itemKey]) {
|
|
482
487
|
json.tabBar[itemKey].forEach((item, index) => {
|
|
483
|
-
|
|
484
|
-
|
|
488
|
+
const iconPath = item[iconKey]
|
|
489
|
+
if (iconPath && isUrlRequest(iconPath)) {
|
|
490
|
+
const iconRequire = wrapTabBarAsset(`require("${addQuery(urlToRequest(iconPath), { useLocal: true })}")`)
|
|
491
|
+
output += `json.tabBar.${itemKey}[${index}].${iconKey} = ${iconRequire};\n`
|
|
485
492
|
}
|
|
486
|
-
|
|
487
|
-
|
|
493
|
+
const activeIconPath = item[activeIconKey]
|
|
494
|
+
if (activeIconPath && isUrlRequest(activeIconPath)) {
|
|
495
|
+
const activeIconRequire = wrapTabBarAsset(`require("${addQuery(urlToRequest(activeIconPath), { useLocal: true })}")`)
|
|
496
|
+
output += `json.tabBar.${itemKey}[${index}].${activeIconKey} = ${activeIconRequire};\n`
|
|
488
497
|
}
|
|
489
498
|
})
|
|
490
499
|
}
|
package/lib/loader.js
CHANGED
|
@@ -19,6 +19,10 @@ const processWeb = require('./web')
|
|
|
19
19
|
const processReact = require('./react')
|
|
20
20
|
const genMpxCustomElement = require('./runtime-render/gen-mpx-custom-element')
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @this {MpxLoaderContext<any>}
|
|
24
|
+
* @param {string} content
|
|
25
|
+
*/
|
|
22
26
|
module.exports = function (content) {
|
|
23
27
|
this.cacheable()
|
|
24
28
|
|
|
@@ -179,6 +179,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
179
179
|
swan: addGlobalComponents,
|
|
180
180
|
qq: addGlobalComponents,
|
|
181
181
|
tt: addGlobalComponents,
|
|
182
|
+
ks: addGlobalComponents,
|
|
182
183
|
jd: addGlobalComponents,
|
|
183
184
|
web: fixComponentName,
|
|
184
185
|
ios: fixComponentName,
|
|
@@ -284,6 +285,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
284
285
|
'swan',
|
|
285
286
|
'qq',
|
|
286
287
|
'tt',
|
|
288
|
+
'ks',
|
|
287
289
|
'jd',
|
|
288
290
|
'qa',
|
|
289
291
|
'dd',
|
|
@@ -401,6 +403,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
401
403
|
qq: fillGlobalComponents,
|
|
402
404
|
swan: fillGlobalComponents,
|
|
403
405
|
tt: fillGlobalComponents,
|
|
406
|
+
ks: fillGlobalComponents,
|
|
404
407
|
jd: fillGlobalComponents
|
|
405
408
|
},
|
|
406
409
|
{
|
|
@@ -408,6 +411,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
408
411
|
qq: deletePath({ noLog: true }),
|
|
409
412
|
swan: deletePath({ noLog: true }),
|
|
410
413
|
tt: deletePath({ noLog: true }),
|
|
414
|
+
ks: deletePath({ noLog: true }),
|
|
411
415
|
jd: deletePath({ noLog: true })
|
|
412
416
|
},
|
|
413
417
|
{
|
|
@@ -446,6 +450,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
446
450
|
qq: getTabBarRule(),
|
|
447
451
|
swan: getTabBarRule(),
|
|
448
452
|
tt: getTabBarRule(),
|
|
453
|
+
ks: getTabBarRule(),
|
|
449
454
|
jd: getTabBarRule()
|
|
450
455
|
},
|
|
451
456
|
{
|
|
@@ -454,6 +459,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
454
459
|
qq: getWindowRule(),
|
|
455
460
|
swan: getWindowRule(),
|
|
456
461
|
tt: getWindowRule(),
|
|
462
|
+
ks: getWindowRule(),
|
|
457
463
|
jd: getWindowRule()
|
|
458
464
|
}
|
|
459
465
|
]
|