@mpxjs/webpack-plugin 2.10.17 → 2.10.18
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 +58 -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 +13 -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 +9 -0
- 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/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-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-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 +10 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +95 -61
- 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/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-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-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +115 -60
- 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/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/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 +2 -5
- 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/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')
|
|
@@ -58,7 +59,6 @@ const wxssLoaderPath = normalize.lib('wxss/index')
|
|
|
58
59
|
const wxmlLoaderPath = normalize.lib('wxml/loader')
|
|
59
60
|
const wxsLoaderPath = normalize.lib('wxs/loader')
|
|
60
61
|
const styleCompilerPath = normalize.lib('style-compiler/index')
|
|
61
|
-
const styleStripConditionalPath = normalize.lib('style-compiler/strip-conditional-loader')
|
|
62
62
|
const templateCompilerPath = normalize.lib('template-compiler/index')
|
|
63
63
|
const jsonCompilerPath = normalize.lib('json-compiler/index')
|
|
64
64
|
const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
|
|
@@ -79,13 +79,17 @@ const LoadAsyncChunkModule = require('./react/LoadAsyncChunkModule')
|
|
|
79
79
|
const ExternalModule = require('webpack/lib/ExternalModule')
|
|
80
80
|
const { RetryRuntimeModule, RetryRuntimeGlobal } = require('./dependencies/RetryRuntimeModule')
|
|
81
81
|
const checkVersionCompatibility = require('./utils/check-core-version-match')
|
|
82
|
-
|
|
82
|
+
const { startFSStripForCss, registerStripCompilation } = require('./style-compiler/strip-conditional')
|
|
83
83
|
checkVersionCompatibility()
|
|
84
84
|
|
|
85
85
|
const isProductionLikeMode = options => {
|
|
86
86
|
return options.mode === 'production' || !options.mode
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @param {import('webpack').NormalModule} module
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
89
93
|
const isStaticModule = module => {
|
|
90
94
|
if (!module.resource) return false
|
|
91
95
|
const { queryObj } = parseRequest(module.resource)
|
|
@@ -322,7 +326,13 @@ class MpxWebpackPlugin {
|
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
|
|
329
|
+
/**
|
|
330
|
+
* @param {import('webpack').Compiler} compiler
|
|
331
|
+
*/
|
|
325
332
|
apply (compiler) {
|
|
333
|
+
// 注入 fs 代理
|
|
334
|
+
startFSStripForCss(this.options.defs)
|
|
335
|
+
|
|
326
336
|
if (!compiler.__mpx__) {
|
|
327
337
|
compiler.__mpx__ = true
|
|
328
338
|
} else {
|
|
@@ -706,6 +716,7 @@ class MpxWebpackPlugin {
|
|
|
706
716
|
})
|
|
707
717
|
|
|
708
718
|
compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
|
|
719
|
+
registerStripCompilation(compilation)
|
|
709
720
|
compilation.warnings.push(...warnings)
|
|
710
721
|
compilation.errors.push(...errors)
|
|
711
722
|
const moduleGraph = compilation.moduleGraph
|
|
@@ -1444,6 +1455,7 @@ class MpxWebpackPlugin {
|
|
|
1444
1455
|
const context = parser.state.module.context
|
|
1445
1456
|
const { queryObj, resourcePath } = parseRequest(request)
|
|
1446
1457
|
let tarRoot = queryObj.root
|
|
1458
|
+
|
|
1447
1459
|
if (!tarRoot && mpx.asyncSubpackageRules) {
|
|
1448
1460
|
for (const item of mpx.asyncSubpackageRules) {
|
|
1449
1461
|
if (matchCondition(resourcePath, item)) {
|
|
@@ -1452,49 +1464,49 @@ class MpxWebpackPlugin {
|
|
|
1452
1464
|
}
|
|
1453
1465
|
}
|
|
1454
1466
|
}
|
|
1455
|
-
|
|
1467
|
+
// TODO 后续考虑和 asyncSubpackageRules 配置合并
|
|
1468
|
+
if (isReact(mpx.mode)) tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
|
|
1469
|
+
|
|
1470
|
+
if (tarRoot && mpx.supportRequireAsync) {
|
|
1456
1471
|
// 删除root query
|
|
1457
1472
|
if (queryObj.root) request = addQuery(request, {}, false, ['root'])
|
|
1458
1473
|
// 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
|
-
}
|
|
1474
|
+
if (isWeb(mpx.mode) || isReact(mpx.mode)) {
|
|
1475
|
+
const depBlock = new AsyncDependenciesBlock(
|
|
1476
|
+
{
|
|
1477
|
+
name: tarRoot + '/index'
|
|
1478
|
+
},
|
|
1479
|
+
expr.loc,
|
|
1480
|
+
request
|
|
1481
|
+
)
|
|
1482
|
+
const dep = new ImportDependency(request, expr.range, undefined, {
|
|
1483
|
+
isRequireAsync: true,
|
|
1484
|
+
retryRequireAsync: this.options.retryRequireAsync
|
|
1485
|
+
})
|
|
1486
|
+
dep.loc = expr.loc
|
|
1487
|
+
depBlock.addDependency(dep)
|
|
1488
|
+
parser.state.current.addBlock(depBlock)
|
|
1488
1489
|
} else {
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1490
|
+
const dep = new DynamicEntryDependency(range, request, 'export', '', tarRoot, '', context, {
|
|
1491
|
+
isAsync: true,
|
|
1492
|
+
isRequireAsync: true,
|
|
1493
|
+
retryRequireAsync: this.options.retryRequireAsync,
|
|
1494
|
+
requireAsyncRange: expr.range
|
|
1495
|
+
})
|
|
1496
|
+
|
|
1497
|
+
parser.state.current.addPresentationalDependency(dep)
|
|
1498
|
+
// 包含require.async的模块不能被concatenate,避免DynamicEntryDependency中无法获取模块chunk以计算相对路径
|
|
1499
|
+
parser.state.module.buildInfo.moduleConcatenationBailout = 'require async'
|
|
1492
1500
|
}
|
|
1493
|
-
if (args) parser.walkExpressions(args)
|
|
1494
|
-
return true
|
|
1495
1501
|
} else {
|
|
1496
|
-
|
|
1502
|
+
const dep = new CommonJsAsyncDependency(request, expr.range)
|
|
1503
|
+
parser.state.current.addDependency(dep)
|
|
1504
|
+
if (!tarRoot) {
|
|
1505
|
+
compilation.warnings.push(new Error(`The require async JS [${request}] need to declare subpackage name by root`))
|
|
1506
|
+
}
|
|
1497
1507
|
}
|
|
1508
|
+
if (args) parser.walkExpressions(args)
|
|
1509
|
+
return true
|
|
1498
1510
|
}
|
|
1499
1511
|
}
|
|
1500
1512
|
|
|
@@ -1729,7 +1741,14 @@ class MpxWebpackPlugin {
|
|
|
1729
1741
|
|
|
1730
1742
|
if (isReact(mpx.mode)) {
|
|
1731
1743
|
// 添加 @refresh reset 注释用于在 React HMR 时刷新组件
|
|
1732
|
-
|
|
1744
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1745
|
+
source.add(`/* @refresh reset */
|
|
1746
|
+
if (module.hot) {
|
|
1747
|
+
module.hot.accept(() => {
|
|
1748
|
+
require("react-native").DevSettings.reload();
|
|
1749
|
+
});
|
|
1750
|
+
}\n`)
|
|
1751
|
+
}
|
|
1733
1752
|
// 注入页面的配置,供screen前置设置导航情况
|
|
1734
1753
|
if (isRuntime) {
|
|
1735
1754
|
source.add('// inject pageconfigmap for screen\n' +
|
|
@@ -1907,42 +1926,9 @@ try {
|
|
|
1907
1926
|
normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
|
|
1908
1927
|
const { queryObj } = parseRequest(createData.request)
|
|
1909
1928
|
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
1929
|
if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
|
|
1941
1930
|
const type = queryObj.type
|
|
1942
1931
|
const extract = queryObj.extract
|
|
1943
|
-
if (type === 'styles') {
|
|
1944
|
-
injectStyleStripLoader(loaders)
|
|
1945
|
-
}
|
|
1946
1932
|
|
|
1947
1933
|
switch (type) {
|
|
1948
1934
|
case 'styles':
|
|
@@ -1995,7 +1981,6 @@ try {
|
|
|
1995
1981
|
}
|
|
1996
1982
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
1997
1983
|
if (isWeb(mpx.mode) && queryObj.mpxStyleOptions) {
|
|
1998
|
-
injectStyleStripLoader(loaders)
|
|
1999
1984
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
2000
1985
|
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
2001
1986
|
let cssLoaderIndex = -1
|
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
|
]
|