@mpxjs/webpack-plugin 2.10.16 → 2.10.17
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/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/helpers.js +2 -0
- package/lib/index.js +40 -15
- package/lib/json-compiler/helper.js +72 -2
- package/lib/json-compiler/index.js +14 -54
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +10 -4
- package/lib/native-loader.js +6 -3
- package/lib/platform/json/wx/index.js +24 -29
- package/lib/platform/style/wx/index.js +8 -1
- package/lib/platform/template/wx/component-config/button.js +12 -3
- package/lib/platform/template/wx/component-config/component.js +31 -33
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
- package/lib/react/index.js +2 -0
- package/lib/react/processJSON.js +39 -71
- package/lib/react/processStyles.js +3 -2
- package/lib/react/processTemplate.js +8 -6
- package/lib/react/script-helper.js +6 -16
- package/lib/react/style-helper.js +10 -2
- package/lib/runtime/components/react/context.ts +12 -6
- package/lib/runtime/components/react/dist/context.d.ts +75 -0
- package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
- package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.jsx +107 -57
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts +50 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +32 -8
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +58 -50
- package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +12 -18
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +10 -2
- package/lib/runtime/components/react/dist/parser.d.ts +40 -0
- package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.d.ts +123 -0
- package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.jsx +16 -6
- package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -1
- package/lib/runtime/components/react/mpx-image.tsx +130 -77
- package/lib/runtime/components/react/mpx-input.tsx +38 -15
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +66 -49
- package/lib/runtime/components/react/mpx-nav.tsx +155 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +26 -21
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
- package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +1 -1
- package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
- package/lib/runtime/components/react/mpx-text.tsx +38 -5
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-web-view.tsx +13 -4
- package/lib/runtime/components/react/types/common.d.ts +19 -0
- package/lib/runtime/components/react/utils.tsx +15 -6
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +3 -2
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +10 -2
- package/lib/style-compiler/strip-conditional-loader.js +177 -15
- package/lib/template-compiler/compiler.js +268 -70
- package/lib/template-compiler/gen-node-react.js +18 -6
- package/lib/template-compiler/index.js +6 -4
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/const.js +2 -1
- package/lib/utils/dom-tag-config.js +5 -5
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-build-tag-component.js +35 -0
- package/lib/utils/merge-visitors.js +55 -0
- package/lib/utils/pre-process-json.js +5 -0
- package/lib/web/index.js +2 -0
- package/lib/web/processJSON.js +44 -16
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +6 -4
- package/lib/web/script-helper.js +19 -9
- package/lib/wxs/pre-loader.js +9 -6
- package/lib/wxss/loader.js +1 -9
- package/package.json +15 -5
- package/lib/utils/chain-assign.js +0 -47
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const normalize = require('./normalize')
|
|
2
|
+
const { isBuildInWebTag, isBuildInReactTag } = require('./dom-tag-config')
|
|
3
|
+
|
|
4
|
+
module.exports = function getBuildInTagComponent (mode, tag) {
|
|
5
|
+
const aliBuildTag = ['view', 'text'].reduce((obj, name) => {
|
|
6
|
+
obj[name] = {
|
|
7
|
+
name: `mpx-${name}`,
|
|
8
|
+
resource: normalize.lib(`runtime/components/ali/mpx-${name}.mpx`)
|
|
9
|
+
}
|
|
10
|
+
return obj
|
|
11
|
+
}, {})
|
|
12
|
+
|
|
13
|
+
switch (mode) {
|
|
14
|
+
case 'ali':
|
|
15
|
+
return aliBuildTag[tag]
|
|
16
|
+
case 'web':
|
|
17
|
+
if (isBuildInWebTag(`mpx-${tag}`)) {
|
|
18
|
+
return {
|
|
19
|
+
name: `mpx-${tag}`,
|
|
20
|
+
resource: normalize.lib(`runtime/components/web/mpx-${tag}.vue`)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined
|
|
24
|
+
case 'ios':
|
|
25
|
+
case 'android':
|
|
26
|
+
case 'harmony':
|
|
27
|
+
if (isBuildInReactTag(`mpx-${tag}`)) {
|
|
28
|
+
return {
|
|
29
|
+
name: `mpx-${tag}`,
|
|
30
|
+
resource: normalize.lib(`runtime/components/react/dist/mpx-${tag}.jsx`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 链式合并方法的工具函数
|
|
3
|
+
*
|
|
4
|
+
* 在多条件分支下使用 Object.assign 会导致同名方法被覆盖,
|
|
5
|
+
* 这个函数通过创建组合函数来确保所有方法都能按顺序执行。
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} target - 目标 visitor 对象
|
|
8
|
+
* @param {Object} source - 要链式分配的 visitor 方法对象
|
|
9
|
+
**/
|
|
10
|
+
|
|
11
|
+
// 辅助函数:将 visitor 的所有钩子添加到结果中
|
|
12
|
+
function mergeVisitorHooks (result, visitor) {
|
|
13
|
+
result.enter = result.enter.concat(visitor.enter)
|
|
14
|
+
result.exit = result.exit.concat(visitor.exit)
|
|
15
|
+
return result
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizeVisitor(visitor) {
|
|
19
|
+
if (Array.isArray(visitor.enter) && Array.isArray(visitor.exit)) {
|
|
20
|
+
return visitor
|
|
21
|
+
}
|
|
22
|
+
if (typeof visitor === 'function') {
|
|
23
|
+
return { enter: [visitor], exit: [] }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (visitor.enter) {
|
|
27
|
+
if (!Array.isArray(visitor.enter)) {
|
|
28
|
+
visitor.enter = [visitor.enter]
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
visitor.enter = []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (visitor.exit) {
|
|
35
|
+
if (!Array.isArray(visitor.exit)) {
|
|
36
|
+
visitor.exit = [visitor.exit]
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
visitor.exit = []
|
|
40
|
+
}
|
|
41
|
+
return visitor
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = function mergeVisitors (target, source) {
|
|
45
|
+
for (const [key, value] of Object.entries(source)) {
|
|
46
|
+
if (!target[key]) {
|
|
47
|
+
target[key] = normalizeVisitor(value)
|
|
48
|
+
} else {
|
|
49
|
+
// 合并现有值和新值
|
|
50
|
+
target[key] = mergeVisitorHooks(normalizeVisitor(target[key]), normalizeVisitor(value))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return target
|
|
55
|
+
}
|
|
@@ -31,6 +31,7 @@ module.exports = function ({
|
|
|
31
31
|
let componentGenerics = {}
|
|
32
32
|
const usingComponentsInfo = {}
|
|
33
33
|
const usingComponents = {}
|
|
34
|
+
let originalUsingComponents
|
|
34
35
|
const finalCallback = (err) => {
|
|
35
36
|
if (err) return callback(err)
|
|
36
37
|
if (ctorType === 'app') {
|
|
@@ -43,6 +44,7 @@ module.exports = function ({
|
|
|
43
44
|
componentPlaceholder,
|
|
44
45
|
componentGenerics,
|
|
45
46
|
usingComponentsInfo: Object.assign({}, usingComponentsInfo, mpx.globalComponentsInfo),
|
|
47
|
+
originalUsingComponents,
|
|
46
48
|
jsonContent
|
|
47
49
|
})
|
|
48
50
|
}
|
|
@@ -61,6 +63,9 @@ module.exports = function ({
|
|
|
61
63
|
if (ctorType !== 'app') {
|
|
62
64
|
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
63
65
|
}
|
|
66
|
+
|
|
67
|
+
originalUsingComponents = ret.usingComponents ? Object.keys(ret.usingComponents) : []
|
|
68
|
+
|
|
64
69
|
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
65
70
|
try {
|
|
66
71
|
if (rulesRunner) rulesRunner(ret)
|
package/lib/web/index.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = function ({
|
|
|
21
21
|
hasComment,
|
|
22
22
|
isNative,
|
|
23
23
|
usingComponentsInfo,
|
|
24
|
+
originalUsingComponents,
|
|
24
25
|
componentGenerics,
|
|
25
26
|
autoScope,
|
|
26
27
|
callback
|
|
@@ -70,6 +71,7 @@ module.exports = function ({
|
|
|
70
71
|
moduleId,
|
|
71
72
|
ctorType,
|
|
72
73
|
usingComponentsInfo,
|
|
74
|
+
originalUsingComponents,
|
|
73
75
|
componentGenerics
|
|
74
76
|
}, callback)
|
|
75
77
|
},
|
package/lib/web/processJSON.js
CHANGED
|
@@ -37,23 +37,38 @@ module.exports = function (jsonContent, {
|
|
|
37
37
|
|
|
38
38
|
const emitWarning = (msg) => {
|
|
39
39
|
loaderContext.emitWarning(
|
|
40
|
-
new Error('[json
|
|
40
|
+
new Error('[Mpx json warning][' + loaderContext.resource + ']: ' + msg)
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const emitError = (msg) => {
|
|
45
45
|
loaderContext.emitError(
|
|
46
|
-
new Error('[json
|
|
46
|
+
new Error('[Mpx json error][' + loaderContext.resource + ']: ' + msg)
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
|
51
51
|
|
|
52
|
+
function fillInComponentsMap (name, entry, tarRoot) {
|
|
53
|
+
const { resource, outputPath } = entry
|
|
54
|
+
const { resourcePath } = parseRequest(resource)
|
|
55
|
+
componentsMap[resourcePath] = outputPath
|
|
56
|
+
loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
|
|
57
|
+
localComponentsMap[name] = {
|
|
58
|
+
resource: addQuery(resource, {
|
|
59
|
+
isComponent: true,
|
|
60
|
+
outputPath
|
|
61
|
+
}),
|
|
62
|
+
async: tarRoot
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
const {
|
|
53
67
|
isUrlRequest,
|
|
54
68
|
urlToRequest,
|
|
55
69
|
processPage,
|
|
56
|
-
processComponent
|
|
70
|
+
processComponent,
|
|
71
|
+
processPlaceholder
|
|
57
72
|
} = createJSONHelper({
|
|
58
73
|
loaderContext,
|
|
59
74
|
emitWarning,
|
|
@@ -240,7 +255,7 @@ module.exports = function (jsonContent, {
|
|
|
240
255
|
if (oldResourcePath !== resourcePath) {
|
|
241
256
|
const oldOutputPath = outputPath
|
|
242
257
|
outputPath = mpx.getOutputPath(resourcePath, 'page', { conflictPath: outputPath })
|
|
243
|
-
emitWarning(
|
|
258
|
+
emitWarning(`Current page [${resourcePath}] is registered with a conflict outputPath [${oldOutputPath}] which is already existed in system, will be renamed with [${outputPath}], use ?resolve to get the real outputPath!`)
|
|
244
259
|
}
|
|
245
260
|
}
|
|
246
261
|
|
|
@@ -287,22 +302,35 @@ module.exports = function (jsonContent, {
|
|
|
287
302
|
|
|
288
303
|
const processComponents = (components, context, callback) => {
|
|
289
304
|
if (components) {
|
|
305
|
+
const asyncComponents = []
|
|
306
|
+
const resolveResourcePathMap = new Map()
|
|
290
307
|
async.eachOf(components, (component, name, callback) => {
|
|
291
|
-
processComponent(component, context, {}, (err,
|
|
308
|
+
processComponent(component, context, {}, (err, entry = {}, { tarRoot, placeholder, resourcePath } = {}) => {
|
|
292
309
|
if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
|
|
293
|
-
const {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
310
|
+
const { relativePath, resource } = entry
|
|
311
|
+
const { queryObj } = parseRequest(resource)
|
|
312
|
+
|
|
313
|
+
tarRoot = queryObj.async || tarRoot
|
|
314
|
+
|
|
315
|
+
resolveResourcePathMap.set(name, resourcePath)
|
|
316
|
+
if (tarRoot) asyncComponents.push({ name, tarRoot, placeholder, relativePath })
|
|
317
|
+
|
|
318
|
+
fillInComponentsMap(name, entry, tarRoot)
|
|
303
319
|
callback()
|
|
304
320
|
})
|
|
305
|
-
},
|
|
321
|
+
}, (err) => {
|
|
322
|
+
if (err) return callback(err)
|
|
323
|
+
async.each(asyncComponents, ({ name, tarRoot, placeholder, relativePath }, callback) => {
|
|
324
|
+
processPlaceholder({ jsonObj, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, (err, placeholder) => {
|
|
325
|
+
if (err) return callback(err)
|
|
326
|
+
if (placeholder) {
|
|
327
|
+
const { name, entry } = placeholder
|
|
328
|
+
fillInComponentsMap(name, entry, '')
|
|
329
|
+
}
|
|
330
|
+
callback()
|
|
331
|
+
})
|
|
332
|
+
}, callback)
|
|
333
|
+
})
|
|
306
334
|
} else {
|
|
307
335
|
callback()
|
|
308
336
|
}
|
package/lib/web/processScript.js
CHANGED
|
@@ -78,12 +78,12 @@ module.exports = function (script, {
|
|
|
78
78
|
}
|
|
79
79
|
content += getRequireScript({ ctorType, script, loaderContext })
|
|
80
80
|
content += `
|
|
81
|
+
// @ts-ignore
|
|
81
82
|
export default processComponentOption({
|
|
82
83
|
option: global.__mpxOptionsMap[${JSON.stringify(moduleId)}],
|
|
83
84
|
ctorType: ${JSON.stringify(ctorType)},
|
|
84
85
|
outputPath: ${JSON.stringify(outputPath)},
|
|
85
86
|
pageConfig: ${JSON.stringify(pageConfig)},
|
|
86
|
-
// @ts-ignore
|
|
87
87
|
componentsMap: ${shallowStringify(componentsMap)},
|
|
88
88
|
componentGenerics: ${JSON.stringify(componentGenerics)},
|
|
89
89
|
genericsInfo: ${JSON.stringify(genericsInfo)},
|
|
@@ -13,6 +13,7 @@ module.exports = function (template, {
|
|
|
13
13
|
moduleId,
|
|
14
14
|
ctorType,
|
|
15
15
|
usingComponentsInfo,
|
|
16
|
+
originalUsingComponents,
|
|
16
17
|
componentGenerics
|
|
17
18
|
}, callback) {
|
|
18
19
|
const mpx = loaderContext.getMpx()
|
|
@@ -51,10 +52,10 @@ module.exports = function (template, {
|
|
|
51
52
|
if (template) {
|
|
52
53
|
// 由于远端src template资源引用的相对路径可能发生变化,暂时不支持。
|
|
53
54
|
if (template.src) {
|
|
54
|
-
return callback(new Error('[
|
|
55
|
+
return callback(new Error('[Mpx template error][' + loaderContext.resource + ']: ' + 'template content must be inline in .mpx files!'))
|
|
55
56
|
}
|
|
56
57
|
if (template.lang) {
|
|
57
|
-
return callback(new Error('[
|
|
58
|
+
return callback(new Error('[Mpx template error][' + loaderContext.resource + ']: ' + 'template lang is not supported in trans web mode temporarily, we will support it in the future!'))
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
output += genComponentTag(template, (template) => {
|
|
@@ -65,18 +66,19 @@ module.exports = function (template, {
|
|
|
65
66
|
const templateSrcMode = template.mode || srcMode
|
|
66
67
|
const warn = (msg) => {
|
|
67
68
|
loaderContext.emitWarning(
|
|
68
|
-
new Error('[template
|
|
69
|
+
new Error('[Mpx template error][' + loaderContext.resource + ']: ' + msg)
|
|
69
70
|
)
|
|
70
71
|
}
|
|
71
72
|
const error = (msg) => {
|
|
72
73
|
loaderContext.emitError(
|
|
73
|
-
new Error('[template
|
|
74
|
+
new Error('[Mpx template error][' + loaderContext.resource + ']: ' + msg)
|
|
74
75
|
)
|
|
75
76
|
}
|
|
76
77
|
const { root, meta } = templateCompiler.parse(template.content, {
|
|
77
78
|
warn,
|
|
78
79
|
error,
|
|
79
80
|
usingComponentsInfo, // processTemplate中无其他地方使用,直接透传 string 类型
|
|
81
|
+
originalUsingComponents,
|
|
80
82
|
hasComment,
|
|
81
83
|
isNative,
|
|
82
84
|
ctorType,
|
package/lib/web/script-helper.js
CHANGED
|
@@ -24,19 +24,29 @@ function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderC
|
|
|
24
24
|
Object.keys(localComponentsMap).forEach((componentName) => {
|
|
25
25
|
const componentCfg = localComponentsMap[componentName]
|
|
26
26
|
const componentRequest = stringifyRequest(loaderContext, componentCfg.resource)
|
|
27
|
+
|
|
27
28
|
if (componentCfg.async) {
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
const placeholder = jsonConfig.componentPlaceholder[componentName]
|
|
29
|
+
const placeholder = jsonConfig.componentPlaceholder && jsonConfig.componentPlaceholder[componentName]
|
|
30
|
+
if (placeholder) {
|
|
31
31
|
const placeholderCfg = localComponentsMap[placeholder]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
if (placeholderCfg) {
|
|
33
|
+
if (placeholderCfg.async) {
|
|
34
|
+
loaderContext.emitWarning(
|
|
35
|
+
new Error(`[Mpx json error][${loaderContext.resource}]: componentPlaceholder ${placeholder} should not be a async component, please check!`)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
const placeholderRequest = stringifyRequest(loaderContext, placeholderCfg.resource)
|
|
39
|
+
componentsMap[componentName] = `function(){return {component: import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)}), loading: getComponent(require(${placeholderRequest}))}}`
|
|
40
|
+
} else {
|
|
41
|
+
loaderContext.emitError(
|
|
42
|
+
new Error(`[json processor][${loaderContext.resource}]: componentPlaceholder ${placeholder} is not built-in component or custom component, please check!`)
|
|
36
43
|
)
|
|
44
|
+
componentsMap[componentName] = `function(){return import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)})}`
|
|
37
45
|
}
|
|
38
|
-
componentsMap[componentName] = `function(){return {component: import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)}), loading: getComponent(require(${placeholderRequest}))}}`
|
|
39
46
|
} else {
|
|
47
|
+
loaderContext.emitError(
|
|
48
|
+
new Error(`[json processor][${loaderContext.resource}]: ${componentName} has no componentPlaceholder, please check!`)
|
|
49
|
+
)
|
|
40
50
|
componentsMap[componentName] = `function(){return import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)})}`
|
|
41
51
|
}
|
|
42
52
|
} else {
|
|
@@ -75,7 +85,7 @@ function buildPagesMap ({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBa
|
|
|
75
85
|
}
|
|
76
86
|
} else {
|
|
77
87
|
loaderContext.emitWarning(
|
|
78
|
-
new Error(`[json
|
|
88
|
+
new Error(`[Mpx json error][${loaderContext.resource}]: TabBar page path ${pagePath} is not exist in local page map, please check!`)
|
|
79
89
|
)
|
|
80
90
|
}
|
|
81
91
|
})
|
package/lib/wxs/pre-loader.js
CHANGED
|
@@ -4,7 +4,7 @@ const t = require('@babel/types')
|
|
|
4
4
|
const generate = require('@babel/generator').default
|
|
5
5
|
const parseRequest = require('../utils/parse-request')
|
|
6
6
|
const isEmptyObject = require('../utils/is-empty-object')
|
|
7
|
-
const
|
|
7
|
+
const mergeVisitors = require('../utils/merge-visitors')
|
|
8
8
|
const parseQuery = require('loader-utils').parseQuery
|
|
9
9
|
|
|
10
10
|
module.exports = function (content) {
|
|
@@ -31,7 +31,7 @@ module.exports = function (content) {
|
|
|
31
31
|
' __mpx_args__[i] = arguments[i];\n' +
|
|
32
32
|
'}'
|
|
33
33
|
).program.body
|
|
34
|
-
|
|
34
|
+
mergeVisitors(visitor, {
|
|
35
35
|
Identifier (path) {
|
|
36
36
|
if (path.node.name === 'arguments') {
|
|
37
37
|
path.node.name = '__mpx_args__'
|
|
@@ -66,7 +66,7 @@ module.exports = function (content) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (mode !== 'wx') {
|
|
69
|
-
|
|
69
|
+
mergeVisitors(visitor, {
|
|
70
70
|
CallExpression (path) {
|
|
71
71
|
const callee = path.node.callee
|
|
72
72
|
if (t.isIdentifier(callee) && callee.name === 'getRegExp') {
|
|
@@ -81,7 +81,7 @@ module.exports = function (content) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (mode === 'dd') {
|
|
84
|
-
|
|
84
|
+
mergeVisitors(visitor, {
|
|
85
85
|
MemberExpression (path) {
|
|
86
86
|
const property = path.node.property
|
|
87
87
|
if (
|
|
@@ -96,11 +96,14 @@ module.exports = function (content) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if (!module.wxs) {
|
|
99
|
-
|
|
99
|
+
mergeVisitors(visitor, {
|
|
100
100
|
MemberExpression (path) {
|
|
101
|
+
if (!t.isMemberExpression(path.node)) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
101
104
|
const property = path.node.property
|
|
102
105
|
if (
|
|
103
|
-
(property.name === 'constructor' || property.value === 'constructor') &&
|
|
106
|
+
property && (property.name === 'constructor' || property.value === 'constructor') &&
|
|
104
107
|
!(t.isMemberExpression(path.parent) && path.parentKey === 'object')
|
|
105
108
|
) {
|
|
106
109
|
path.replaceWith(t.memberExpression(path.node, t.identifier('name')))
|
package/lib/wxss/loader.js
CHANGED
|
@@ -32,13 +32,6 @@ const {
|
|
|
32
32
|
} = require('./utils')
|
|
33
33
|
const createHelpers = require('../helpers')
|
|
34
34
|
|
|
35
|
-
const RN_PRESET_OPTIMISATION = {
|
|
36
|
-
reduceInitial: false,
|
|
37
|
-
normalizeWhitespace: false,
|
|
38
|
-
minifyFontValues: false,
|
|
39
|
-
convertValues: false
|
|
40
|
-
}
|
|
41
|
-
|
|
42
35
|
module.exports = async function loader (content, map, meta) {
|
|
43
36
|
const rawOptions = this.getOptions(schema)
|
|
44
37
|
const plugins = []
|
|
@@ -157,12 +150,11 @@ module.exports = async function loader (content, map, meta) {
|
|
|
157
150
|
)
|
|
158
151
|
}
|
|
159
152
|
|
|
160
|
-
if (this.minimize) {
|
|
153
|
+
if (this.minimize && !isRN) {
|
|
161
154
|
const cssnano = require('cssnano')
|
|
162
155
|
const minimizeOptions = rawOptions.minimize || {}
|
|
163
156
|
const presetOptimisation = Object.assign(
|
|
164
157
|
{},
|
|
165
|
-
isRN ? RN_PRESET_OPTIMISATION : {},
|
|
166
158
|
minimizeOptions.optimisation
|
|
167
159
|
)
|
|
168
160
|
let cssnanoConfig = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.17",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@better-scroll/wheel": "^2.5.1",
|
|
30
30
|
"@better-scroll/zoom": "^2.5.1",
|
|
31
31
|
"@mpxjs/template-engine": "^2.8.7",
|
|
32
|
-
"@mpxjs/utils": "^2.10.
|
|
32
|
+
"@mpxjs/utils": "^2.10.17",
|
|
33
33
|
"acorn": "^8.11.3",
|
|
34
34
|
"acorn-walk": "^7.2.0",
|
|
35
35
|
"async": "^2.6.0",
|
|
@@ -51,18 +51,25 @@
|
|
|
51
51
|
"mime": "^2.2.2",
|
|
52
52
|
"object-assign": "^4.1.1",
|
|
53
53
|
"postcss": "^8.4.5",
|
|
54
|
+
"postcss-import": "^16.1.1",
|
|
55
|
+
"postcss-less": "^6.0.0",
|
|
54
56
|
"postcss-load-config": "^3.1.1",
|
|
55
57
|
"postcss-modules-extract-imports": "^3.0.0",
|
|
56
58
|
"postcss-modules-local-by-default": "^4.0.0",
|
|
57
59
|
"postcss-modules-scope": "^3.0.0",
|
|
58
60
|
"postcss-modules-values": "^4.0.0",
|
|
61
|
+
"postcss-scss": "^4.0.9",
|
|
59
62
|
"postcss-selector-parser": "^6.0.8",
|
|
63
|
+
"postcss-styl": "^0.12.3",
|
|
60
64
|
"postcss-value-parser": "^4.0.2",
|
|
61
65
|
"semver": "^7.5.4",
|
|
62
66
|
"source-list-map": "^2.0.0",
|
|
63
67
|
"webpack-virtual-modules": "^0.6.0"
|
|
64
68
|
},
|
|
65
69
|
"peerDependencies": {
|
|
70
|
+
"postcss-less": "^6.0.0",
|
|
71
|
+
"postcss-scss": "^4.0.9",
|
|
72
|
+
"postcss-styl": "^0.12.3",
|
|
66
73
|
"webpack": "^5.75.0"
|
|
67
74
|
},
|
|
68
75
|
"publishConfig": {
|
|
@@ -78,16 +85,19 @@
|
|
|
78
85
|
"url": "https://github.com/didi/mpx/issues"
|
|
79
86
|
},
|
|
80
87
|
"scripts": {
|
|
81
|
-
"test": "jest",
|
|
88
|
+
"test": "jest --passWithNoTests",
|
|
82
89
|
"copy-icons": "cp -r ./lib/runtime/components/react/mpx-icon/icons ./lib/runtime/components/react/dist/mpx-icon/icons",
|
|
83
90
|
"build": "rimraf ./lib/runtime/components/react/dist && tsc && npm run copy-icons"
|
|
84
91
|
},
|
|
85
92
|
"devDependencies": {
|
|
86
93
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
87
|
-
"@mpxjs/api-proxy": "^2.10.
|
|
94
|
+
"@mpxjs/api-proxy": "^2.10.17",
|
|
88
95
|
"@types/babel-traverse": "^6.25.4",
|
|
89
96
|
"@types/babel-types": "^7.0.4",
|
|
97
|
+
"@types/glob": "^8.1.0",
|
|
98
|
+
"@types/postcss-import": "^14.0.3",
|
|
90
99
|
"@types/react": "^18.2.79",
|
|
100
|
+
"glob": "^11.0.2",
|
|
91
101
|
"react-native": "^0.74.5",
|
|
92
102
|
"react-native-gesture-handler": "^2.18.1",
|
|
93
103
|
"react-native-linear-gradient": "^2.8.3",
|
|
@@ -101,5 +111,5 @@
|
|
|
101
111
|
"engines": {
|
|
102
112
|
"node": ">=14.14.0"
|
|
103
113
|
},
|
|
104
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "33fbd0bb8d4b83555239a8931fabb23022af0866"
|
|
105
115
|
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 链式合并方法的工具函数
|
|
3
|
-
*
|
|
4
|
-
* 在多条件分支下使用 Object.assign 会导致同名方法被覆盖,
|
|
5
|
-
* 这个函数通过创建组合函数来确保所有方法都能按顺序执行。
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} target - 目标 visitor 对象
|
|
8
|
-
* @param {Object} source - 要链式分配的 visitor 方法对象
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const visitor = {}
|
|
12
|
-
*
|
|
13
|
-
* // 第一次合并
|
|
14
|
-
* chainAssign(visitor, {
|
|
15
|
-
* CallExpression(path) {
|
|
16
|
-
* console.log('第一个处理器')
|
|
17
|
-
* }
|
|
18
|
-
* })
|
|
19
|
-
*
|
|
20
|
-
* // 第二次合并 - 不会覆盖,而是组合执行
|
|
21
|
-
* chainAssign(visitor, {
|
|
22
|
-
* CallExpression(path) {
|
|
23
|
-
* console.log('第二个处理器')
|
|
24
|
-
* }
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* // 执行时会依次输出:
|
|
28
|
-
* // 第一个处理器
|
|
29
|
-
* // 第二个处理器
|
|
30
|
-
*/
|
|
31
|
-
module.exports = function chainAssign (target, source) {
|
|
32
|
-
for (const [key, value] of Object.entries(source)) {
|
|
33
|
-
if (target[key]) {
|
|
34
|
-
// 如果已存在同名方法,创建组合函数依次执行
|
|
35
|
-
const originalMethod = target[key]
|
|
36
|
-
target[key] = function (path) {
|
|
37
|
-
originalMethod.call(this, path)
|
|
38
|
-
// 只有当节点没有停止遍历或被移除时才继续执行
|
|
39
|
-
if (!path.removed && !path.shouldStop) {
|
|
40
|
-
value.call(this, path)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
target[key] = value
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|