@mpxjs/webpack-plugin 2.10.16 → 2.10.17-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/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 +228 -13
- package/lib/template-compiler/compiler.js +267 -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 +7 -5
- package/LICENSE +0 -433
- package/lib/utils/chain-assign.js +0 -47
|
@@ -21,8 +21,8 @@ class AppEntryDependency extends NullDependency {
|
|
|
21
21
|
if (mpx.appInfo.name) {
|
|
22
22
|
const issuer = moduleGraph.getIssuer(module)
|
|
23
23
|
const err = new Error(issuer
|
|
24
|
-
? `[json
|
|
25
|
-
: `[json
|
|
24
|
+
? `[Mpx json error]:Mpx单次构建中只能存在一个App,当前组件/页面[${module.resource}]通过[${issuer.resource}]非法引入,引用的资源将被忽略,请确保组件/页面资源通过usingComponents/pages配置引入!`
|
|
25
|
+
: `[Mpx json error]:Mpx单次构建中只能存在一个App,请检查当前entry中的资源[${module.resource}]是否为组件/页面,通过添加?component/page查询字符串显式声明该资源是组件/页面!`)
|
|
26
26
|
return callback(err)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const NullDependency = require('webpack/lib/dependencies/NullDependency')
|
|
2
|
+
const makeSerializable = require('webpack/lib/util/makeSerializable')
|
|
3
|
+
|
|
4
|
+
class RecordModuleIdMapDependency extends NullDependency {
|
|
5
|
+
constructor (moduleId, filePath) {
|
|
6
|
+
super()
|
|
7
|
+
this.moduleId = moduleId
|
|
8
|
+
this.filePath = filePath
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get type () {
|
|
12
|
+
return 'mpx record module id map'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
mpxAction (module, compilation, callback) {
|
|
16
|
+
const mpx = compilation.__mpx__
|
|
17
|
+
const { moduleId, filePath } = this
|
|
18
|
+
// 确保 resourceModuleIdMap 存在
|
|
19
|
+
if (!mpx.resourceModuleIdMap) {
|
|
20
|
+
mpx.resourceModuleIdMap = {}
|
|
21
|
+
}
|
|
22
|
+
// 记录 moduleId 和 filePath 的映射关系
|
|
23
|
+
mpx.resourceModuleIdMap[moduleId] = filePath
|
|
24
|
+
return callback()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
serialize (context) {
|
|
28
|
+
const { write } = context
|
|
29
|
+
write(this.moduleId)
|
|
30
|
+
write(this.filePath)
|
|
31
|
+
super.serialize(context)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
deserialize (context) {
|
|
35
|
+
const { read } = context
|
|
36
|
+
this.moduleId = read()
|
|
37
|
+
this.filePath = read()
|
|
38
|
+
super.deserialize(context)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
RecordModuleIdMapDependency.Template = class RecordModuleIdMapDependencyTemplate {
|
|
43
|
+
apply () {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
makeSerializable(RecordModuleIdMapDependency, '@mpxjs/webpack-plugin/lib/dependencies/RecordModuleIdMapDependency')
|
|
48
|
+
|
|
49
|
+
module.exports = RecordModuleIdMapDependency
|
|
@@ -36,7 +36,7 @@ class ResolveDependency extends NullDependency {
|
|
|
36
36
|
const resolveResult = pagesMap[resourcePath] || currentComponentsMap[resourcePath] || mainComponentsMap[resourcePath] || currentStaticResourcesMap[resourcePath] || mainStaticResourcesMap[resourcePath] || ''
|
|
37
37
|
if (!resolveResult) {
|
|
38
38
|
if (!partialCompileRules || matchCondition(resourcePath, partialCompileRules)) {
|
|
39
|
-
compilation.errors.push(new Error(`Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
|
|
39
|
+
compilation.errors.push(new Error(`[Mpx json error]:Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return resolveResult
|
package/lib/helpers.js
CHANGED
|
@@ -69,6 +69,8 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
69
69
|
if (part.useJSONJS) options.useJSONJS = true
|
|
70
70
|
// eslint-disable-next-line no-fallthrough
|
|
71
71
|
case 'styles':
|
|
72
|
+
options.lang = part.lang
|
|
73
|
+
// eslint-disable-next-line no-fallthrough
|
|
72
74
|
case 'template':
|
|
73
75
|
options.extract = true
|
|
74
76
|
}
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const FixDescriptionInfoPlugin = require('./resolver/FixDescriptionInfoPlugin')
|
|
|
36
36
|
const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
37
37
|
const RecordPageConfigMapDependency = require('./dependencies/RecordPageConfigsMapDependency')
|
|
38
38
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
39
|
+
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
39
40
|
const RecordGlobalComponentsDependency = require('./dependencies/RecordGlobalComponentsDependency')
|
|
40
41
|
const RecordIndependentDependency = require('./dependencies/RecordIndependentDependency')
|
|
41
42
|
const DynamicEntryDependency = require('./dependencies/DynamicEntryDependency')
|
|
@@ -673,6 +674,9 @@ class MpxWebpackPlugin {
|
|
|
673
674
|
compilation.dependencyFactories.set(RecordResourceMapDependency, new NullFactory())
|
|
674
675
|
compilation.dependencyTemplates.set(RecordResourceMapDependency, new RecordResourceMapDependency.Template())
|
|
675
676
|
|
|
677
|
+
compilation.dependencyFactories.set(RecordModuleIdMapDependency, new NullFactory())
|
|
678
|
+
compilation.dependencyTemplates.set(RecordModuleIdMapDependency, new RecordModuleIdMapDependency.Template())
|
|
679
|
+
|
|
676
680
|
compilation.dependencyFactories.set(RecordGlobalComponentsDependency, new NullFactory())
|
|
677
681
|
compilation.dependencyTemplates.set(RecordGlobalComponentsDependency, new RecordGlobalComponentsDependency.Template())
|
|
678
682
|
|
|
@@ -721,6 +725,8 @@ class MpxWebpackPlugin {
|
|
|
721
725
|
componentsMap: {
|
|
722
726
|
main: {}
|
|
723
727
|
},
|
|
728
|
+
// 资源与moduleId关系记录
|
|
729
|
+
resourceModuleIdMap: {},
|
|
724
730
|
// 静态资源(图片,字体,独立样式)等,依照所属包进行记录
|
|
725
731
|
staticResourcesMap: {
|
|
726
732
|
main: {}
|
|
@@ -1684,11 +1690,12 @@ class MpxWebpackPlugin {
|
|
|
1684
1690
|
|
|
1685
1691
|
if (this.options.generateBuildMap) {
|
|
1686
1692
|
const pagesMap = compilation.__mpx__.pagesMap
|
|
1693
|
+
const resourceModuleIdMap = compilation.__mpx__.resourceModuleIdMap
|
|
1687
1694
|
const componentsPackageMap = compilation.__mpx__.componentsMap
|
|
1688
1695
|
const componentsMap = Object.keys(componentsPackageMap).map(item => componentsPackageMap[item]).reduce((pre, cur) => {
|
|
1689
1696
|
return { ...pre, ...cur }
|
|
1690
1697
|
}, {})
|
|
1691
|
-
const outputMap = JSON.stringify({ ...pagesMap, ...componentsMap })
|
|
1698
|
+
const outputMap = JSON.stringify({ outputPathMap: { ...pagesMap, ...componentsMap }, moduleIdMap: resourceModuleIdMap })
|
|
1692
1699
|
const filename = this.options.generateBuildMap.filename || 'outputMap.json'
|
|
1693
1700
|
compilation.assets[filename] = new RawSource(outputMap)
|
|
1694
1701
|
}
|
|
@@ -1900,24 +1907,41 @@ try {
|
|
|
1900
1907
|
normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
|
|
1901
1908
|
const { queryObj } = parseRequest(createData.request)
|
|
1902
1909
|
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
|
+
}
|
|
1903
1940
|
if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
|
|
1904
1941
|
const type = queryObj.type
|
|
1905
1942
|
const extract = queryObj.extract
|
|
1906
|
-
|
|
1907
1943
|
if (type === 'styles') {
|
|
1908
|
-
|
|
1909
|
-
// 单次遍历收集所有索引
|
|
1910
|
-
loaders.forEach((loader, index) => {
|
|
1911
|
-
const currentLoader = toPosix(loader.loader)
|
|
1912
|
-
if (currentLoader.includes('node_modules/stylus-loader') || currentLoader.includes('node_modules/sass-loader') || currentLoader.includes('node_modules/less-loader')) {
|
|
1913
|
-
insertBeforeIndex = index
|
|
1914
|
-
}
|
|
1915
|
-
})
|
|
1916
|
-
|
|
1917
|
-
if (insertBeforeIndex !== -1) {
|
|
1918
|
-
loaders.splice(insertBeforeIndex, 0, { loader: styleStripConditionalPath })
|
|
1919
|
-
}
|
|
1920
|
-
loaders.push({ loader: styleStripConditionalPath })
|
|
1944
|
+
injectStyleStripLoader(loaders)
|
|
1921
1945
|
}
|
|
1922
1946
|
|
|
1923
1947
|
switch (type) {
|
|
@@ -1971,6 +1995,7 @@ try {
|
|
|
1971
1995
|
}
|
|
1972
1996
|
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
|
|
1973
1997
|
if (isWeb(mpx.mode) && queryObj.mpxStyleOptions) {
|
|
1998
|
+
injectStyleStripLoader(loaders)
|
|
1974
1999
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
1975
2000
|
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
1976
2001
|
let cssLoaderIndex = -1
|
|
@@ -8,8 +8,10 @@ const loaderUtils = require('loader-utils')
|
|
|
8
8
|
const resolve = require('../utils/resolve')
|
|
9
9
|
const { matchCondition } = require('../utils/match-condition')
|
|
10
10
|
const { isWeb, isReact } = require('../utils/env')
|
|
11
|
+
const getBuildInTagComponent = require('../utils/get-build-tag-component')
|
|
12
|
+
const { capitalToHyphen } = require('../utils/string')
|
|
11
13
|
|
|
12
|
-
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
|
|
14
|
+
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry, emitError }) {
|
|
13
15
|
const mpx = loaderContext.getMpx()
|
|
14
16
|
const resolveMode = mpx.resolveMode
|
|
15
17
|
const externals = mpx.externals
|
|
@@ -158,7 +160,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
158
160
|
const { resourcePath } = parseRequest(resource)
|
|
159
161
|
const relative = path.relative(context, resourcePath)
|
|
160
162
|
if (/^\./.test(relative)) {
|
|
161
|
-
return callback(new Error(`The js export path ${resourcePath} must be in the context ${context}!`))
|
|
163
|
+
return callback(new Error(`[Mpx json error]:The js export path ${resourcePath} must be in the context ${context}!`))
|
|
162
164
|
}
|
|
163
165
|
const outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
164
166
|
const entry = getDynamicEntry(resource, 'export', outputPath, tarRoot, publicPath + tarRoot)
|
|
@@ -166,11 +168,79 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
166
168
|
})
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
const fillInComponentPlaceholder = ({ jsonObj, name: componentName, placeholder, placeholderEntry, resolveResourcePathMap }, callback) => {
|
|
172
|
+
let placeholderComponentName = placeholder.name
|
|
173
|
+
const componentPlaceholder = jsonObj.componentPlaceholder || {}
|
|
174
|
+
if (componentPlaceholder[componentName]) {
|
|
175
|
+
callback()
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
jsonObj.componentPlaceholder = componentPlaceholder
|
|
179
|
+
if (placeholderEntry) {
|
|
180
|
+
if (resolveResourcePathMap.has(placeholderComponentName) && resolveResourcePathMap.get(placeholderComponentName) !== placeholder.resourcePath) {
|
|
181
|
+
// 如果存在placeholder与已有usingComponents冲突, 重新生成一个组件名,在当前组件后增加一个数字
|
|
182
|
+
let i = 1
|
|
183
|
+
let newPlaceholder = placeholderComponentName + i
|
|
184
|
+
while (jsonObj.usingComponents[newPlaceholder]) {
|
|
185
|
+
newPlaceholder = placeholderComponentName + ++i
|
|
186
|
+
}
|
|
187
|
+
placeholderComponentName = newPlaceholder
|
|
188
|
+
}
|
|
189
|
+
jsonObj.usingComponents[placeholderComponentName] = placeholderEntry
|
|
190
|
+
resolveResourcePathMap.set(placeholderComponentName, placeholder.resourcePath)
|
|
191
|
+
}
|
|
192
|
+
componentPlaceholder[componentName] = placeholderComponentName
|
|
193
|
+
callback(null, {
|
|
194
|
+
name: placeholderComponentName,
|
|
195
|
+
entry: placeholderEntry
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const getNormalizePlaceholder = (placeholder) => {
|
|
200
|
+
if (typeof placeholder === 'string') {
|
|
201
|
+
placeholder = getBuildInTagComponent(mode, placeholder) || { name: placeholder }
|
|
202
|
+
}
|
|
203
|
+
if (!placeholder.name) {
|
|
204
|
+
emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
|
|
205
|
+
}
|
|
206
|
+
// ali 下与 rulesRunner 规则一致,组件名驼峰转连字符
|
|
207
|
+
if (mode === 'ali') {
|
|
208
|
+
placeholder.name = capitalToHyphen(placeholder.name)
|
|
209
|
+
}
|
|
210
|
+
return placeholder
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const processPlaceholder = ({ jsonObj, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, callback) => {
|
|
214
|
+
if (tarRoot) {
|
|
215
|
+
if (placeholder) {
|
|
216
|
+
placeholder = getNormalizePlaceholder(placeholder)
|
|
217
|
+
if (placeholder.resource) {
|
|
218
|
+
processComponent(placeholder.resource, context, { relativePath }, (err, entry, { resourcePath }) => {
|
|
219
|
+
if (err) return callback(err)
|
|
220
|
+
placeholder.resourcePath = resourcePath
|
|
221
|
+
fillInComponentPlaceholder({ jsonObj, name, placeholder, placeholderEntry: entry, resolveResourcePathMap }, callback)
|
|
222
|
+
})
|
|
223
|
+
} else {
|
|
224
|
+
fillInComponentPlaceholder({ jsonObj, name, placeholder }, callback)
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
if (!jsonObj.componentPlaceholder || !jsonObj.componentPlaceholder[name]) {
|
|
228
|
+
const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
|
|
229
|
+
emitError(errMsg)
|
|
230
|
+
}
|
|
231
|
+
callback()
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
callback()
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
169
238
|
return {
|
|
170
239
|
processComponent,
|
|
171
240
|
processDynamicEntry,
|
|
172
241
|
processPage,
|
|
173
242
|
processJsExport,
|
|
243
|
+
processPlaceholder,
|
|
174
244
|
isUrlRequest,
|
|
175
245
|
urlToRequest
|
|
176
246
|
}
|
|
@@ -15,9 +15,6 @@ const RecordRuntimeInfoDependency = require('../dependencies/RecordRuntimeInfoDe
|
|
|
15
15
|
const { MPX_DISABLE_EXTRACTOR_CACHE, RESOLVE_IGNORED_ERR, JSON_JS_EXT } = require('../utils/const')
|
|
16
16
|
const resolve = require('../utils/resolve')
|
|
17
17
|
const resolveTabBarPath = require('../utils/resolve-tab-bar-path')
|
|
18
|
-
const normalize = require('../utils/normalize')
|
|
19
|
-
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
20
|
-
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
21
18
|
const resolveMpxCustomElementPath = require('../utils/resolve-mpx-custom-element-path')
|
|
22
19
|
|
|
23
20
|
module.exports = function (content) {
|
|
@@ -43,7 +40,6 @@ module.exports = function (content) {
|
|
|
43
40
|
const globalSrcMode = mpx.srcMode
|
|
44
41
|
const localSrcMode = queryObj.mode
|
|
45
42
|
const srcMode = localSrcMode || globalSrcMode
|
|
46
|
-
const projectRoot = mpx.projectRoot
|
|
47
43
|
|
|
48
44
|
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
49
45
|
const publicPath = this._compilation.outputOptions.publicPath || ''
|
|
@@ -52,46 +48,24 @@ module.exports = function (content) {
|
|
|
52
48
|
|
|
53
49
|
const emitWarning = (msg) => {
|
|
54
50
|
this.emitWarning(
|
|
55
|
-
new Error('[json
|
|
51
|
+
new Error('[Mpx json error][' + this.resource + ']: ' + msg)
|
|
56
52
|
)
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
const emitError = (msg) => {
|
|
60
56
|
this.emitError(
|
|
61
|
-
new Error('[json
|
|
57
|
+
new Error('[Mpx json error][' + this.resource + ']: ' + msg)
|
|
62
58
|
)
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
const fillInComponentPlaceholder = (name, placeholder, placeholderEntry) => {
|
|
66
|
-
const componentPlaceholder = json.componentPlaceholder || {}
|
|
67
|
-
if (componentPlaceholder[name]) return
|
|
68
|
-
componentPlaceholder[name] = placeholder
|
|
69
|
-
json.componentPlaceholder = componentPlaceholder
|
|
70
|
-
if (placeholderEntry && !json.usingComponents[placeholder]) json.usingComponents[placeholder] = placeholderEntry
|
|
71
|
-
}
|
|
72
|
-
const normalizePlaceholder = (placeholder) => {
|
|
73
|
-
if (typeof placeholder === 'string') {
|
|
74
|
-
const placeholderMap = mode === 'ali'
|
|
75
|
-
? {
|
|
76
|
-
view: { name: 'mpx-view', resource: mpxViewPath },
|
|
77
|
-
text: { name: 'mpx-text', resource: mpxTextPath }
|
|
78
|
-
}
|
|
79
|
-
: {}
|
|
80
|
-
placeholder = placeholderMap[placeholder] || { name: placeholder }
|
|
81
|
-
}
|
|
82
|
-
if (!placeholder.name) {
|
|
83
|
-
emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
|
|
84
|
-
}
|
|
85
|
-
return placeholder
|
|
86
|
-
}
|
|
87
|
-
|
|
88
61
|
const {
|
|
89
62
|
isUrlRequest,
|
|
90
63
|
urlToRequest,
|
|
91
64
|
processPage,
|
|
92
65
|
processDynamicEntry,
|
|
93
66
|
processComponent,
|
|
94
|
-
processJsExport
|
|
67
|
+
processJsExport,
|
|
68
|
+
processPlaceholder
|
|
95
69
|
} = createJSONHelper({
|
|
96
70
|
loaderContext: this,
|
|
97
71
|
emitWarning,
|
|
@@ -223,6 +197,9 @@ module.exports = function (content) {
|
|
|
223
197
|
|
|
224
198
|
const processComponents = (components, context, callback) => {
|
|
225
199
|
if (components) {
|
|
200
|
+
// 存在所有命中asyncSubpackageRules的组件
|
|
201
|
+
const asyncComponents = []
|
|
202
|
+
const resolveResourcePathMap = new Map()
|
|
226
203
|
async.eachOf(components, (component, name, callback) => {
|
|
227
204
|
processComponent(component, context, { relativePath }, (err, entry, { tarRoot, placeholder, resourcePath, queryObj = {} } = {}) => {
|
|
228
205
|
if (err === RESOLVE_IGNORED_ERR) {
|
|
@@ -242,29 +219,9 @@ module.exports = function (content) {
|
|
|
242
219
|
isDynamic: queryObj.isDynamic
|
|
243
220
|
}
|
|
244
221
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (placeholder.resource) {
|
|
249
|
-
processComponent(placeholder.resource, projectRoot, { relativePath }, (err, entry) => {
|
|
250
|
-
if (err) return callback(err)
|
|
251
|
-
fillInComponentPlaceholder(name, placeholder.name, entry)
|
|
252
|
-
callback()
|
|
253
|
-
})
|
|
254
|
-
} else {
|
|
255
|
-
fillInComponentPlaceholder(name, placeholder.name)
|
|
256
|
-
callback()
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
if (!json.componentPlaceholder || !json.componentPlaceholder[name]) {
|
|
260
|
-
const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
|
|
261
|
-
emitError(errMsg)
|
|
262
|
-
}
|
|
263
|
-
callback()
|
|
264
|
-
}
|
|
265
|
-
} else {
|
|
266
|
-
callback()
|
|
267
|
-
}
|
|
222
|
+
resolveResourcePathMap.set(name, resourcePath)
|
|
223
|
+
if (tarRoot) asyncComponents.push({ name, tarRoot, placeholder, relativePath })
|
|
224
|
+
callback()
|
|
268
225
|
})
|
|
269
226
|
}, (err) => {
|
|
270
227
|
if (err) return callback(err)
|
|
@@ -279,7 +236,10 @@ module.exports = function (content) {
|
|
|
279
236
|
components.element = mpxCustomElementPath
|
|
280
237
|
Object.assign(components, mpx.getPackageInjectedComponentsMap(packageName))
|
|
281
238
|
}
|
|
282
|
-
callback
|
|
239
|
+
// 使用async处理所有asyncComponents完成后调用callback
|
|
240
|
+
async.each(asyncComponents, ({ name, tarRoot, placeholder, relativePath }, callback) => {
|
|
241
|
+
processPlaceholder({ jsonObj: json, context, name, tarRoot, placeholder, relativePath, resolveResourcePathMap }, callback)
|
|
242
|
+
}, callback)
|
|
283
243
|
})
|
|
284
244
|
} else {
|
|
285
245
|
callback()
|
|
@@ -23,13 +23,13 @@ module.exports = function (source) {
|
|
|
23
23
|
|
|
24
24
|
const emitWarning = (msg) => {
|
|
25
25
|
this.emitWarning(
|
|
26
|
-
new Error('[
|
|
26
|
+
new Error('[Mpx json warning][' + this.resource + ']: ' + msg)
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const emitError = (msg) => {
|
|
31
31
|
this.emitError(
|
|
32
|
-
new Error('[
|
|
32
|
+
new Error('[Mpx json error][' + this.resource + ']: ' + msg)
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
package/lib/loader.js
CHANGED
|
@@ -10,6 +10,7 @@ const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
|
10
10
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
11
11
|
const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDependency')
|
|
12
12
|
const DynamicEntryDependency = require('./dependencies/DynamicEntryDependency')
|
|
13
|
+
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
13
14
|
const tsWatchRunLoaderFilter = require('./utils/ts-loader-watch-run-loader-filter')
|
|
14
15
|
const { isReact } = require('./utils/env')
|
|
15
16
|
const preProcessJson = require('./utils/pre-process-json')
|
|
@@ -50,13 +51,13 @@ module.exports = function (content) {
|
|
|
50
51
|
|
|
51
52
|
const emitWarning = (msg) => {
|
|
52
53
|
this.emitWarning(
|
|
53
|
-
new Error('[
|
|
54
|
+
new Error('[Mpx json warning][' + this.resource + ']: ' + msg)
|
|
54
55
|
)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
const emitError = (msg) => {
|
|
58
59
|
this.emitError(
|
|
59
|
-
new Error('[
|
|
60
|
+
new Error('[Mpx json error][' + this.resource + ']: ' + msg)
|
|
60
61
|
)
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -87,6 +88,7 @@ module.exports = function (content) {
|
|
|
87
88
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
88
89
|
const filePath = this.resourcePath
|
|
89
90
|
const moduleId = mpx.getModuleId(resourcePath, ctorType === 'app')
|
|
91
|
+
this._module.addPresentationalDependency(new RecordModuleIdMapDependency(moduleId, resourcePath))
|
|
90
92
|
|
|
91
93
|
const parts = parseComponent(content, {
|
|
92
94
|
filePath,
|
|
@@ -121,6 +123,7 @@ module.exports = function (content) {
|
|
|
121
123
|
componentPlaceholder,
|
|
122
124
|
componentGenerics,
|
|
123
125
|
usingComponentsInfo,
|
|
126
|
+
originalUsingComponents,
|
|
124
127
|
jsonContent
|
|
125
128
|
} = jsonInfo
|
|
126
129
|
const hasScoped = parts.styles.some(({ scoped }) => scoped) || autoScope
|
|
@@ -144,7 +147,8 @@ module.exports = function (content) {
|
|
|
144
147
|
hasScoped,
|
|
145
148
|
hasComment,
|
|
146
149
|
isNative,
|
|
147
|
-
usingComponentsInfo
|
|
150
|
+
usingComponentsInfo,
|
|
151
|
+
originalUsingComponents,
|
|
148
152
|
componentGenerics,
|
|
149
153
|
autoScope,
|
|
150
154
|
callback
|
|
@@ -166,7 +170,8 @@ module.exports = function (content) {
|
|
|
166
170
|
hasScoped,
|
|
167
171
|
hasComment,
|
|
168
172
|
isNative,
|
|
169
|
-
usingComponentsInfo
|
|
173
|
+
usingComponentsInfo,
|
|
174
|
+
originalUsingComponents,
|
|
170
175
|
componentGenerics,
|
|
171
176
|
autoScope,
|
|
172
177
|
callback
|
|
@@ -235,6 +240,7 @@ module.exports = function (content) {
|
|
|
235
240
|
ctorType,
|
|
236
241
|
moduleId,
|
|
237
242
|
usingComponentsInfo: JSON.stringify(usingComponentsInfo),
|
|
243
|
+
originalUsingComponents: JSON.stringify(originalUsingComponents),
|
|
238
244
|
componentPlaceholder
|
|
239
245
|
// 添加babel处理渲染函数中可能包含的...展开运算符
|
|
240
246
|
// 由于...运算符应用范围极小以及babel成本极高,先关闭此特性后续看情况打开
|
package/lib/native-loader.js
CHANGED
|
@@ -8,6 +8,7 @@ const { JSON_JS_EXT } = require('./utils/const')
|
|
|
8
8
|
const getEntryName = require('./utils/get-entry-name')
|
|
9
9
|
const AppEntryDependency = require('./dependencies/AppEntryDependency')
|
|
10
10
|
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
11
|
+
const RecordModuleIdMapDependency = require('./dependencies/RecordModuleIdMapDependency')
|
|
11
12
|
const preProcessJson = require('./utils/pre-process-json')
|
|
12
13
|
|
|
13
14
|
// todo native-loader考虑与mpx-loader或加强复用,原生组件约等于4个区块都为src的.mpx文件
|
|
@@ -23,7 +24,9 @@ module.exports = function (content) {
|
|
|
23
24
|
const loaderContext = this
|
|
24
25
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
25
26
|
const filePath = this.resourcePath
|
|
26
|
-
const moduleId = mpx.getModuleId(filePath)
|
|
27
|
+
const moduleId = mpx.getModuleId(filePath, false, this)
|
|
28
|
+
this._module.addPresentationalDependency(new RecordModuleIdMapDependency(moduleId, filePath))
|
|
29
|
+
|
|
27
30
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
28
31
|
const packageRoot = queryObj.packageRoot || mpx.currentPackageRoot
|
|
29
32
|
const mode = mpx.mode
|
|
@@ -104,13 +107,13 @@ module.exports = function (content) {
|
|
|
104
107
|
|
|
105
108
|
const emitWarning = (msg) => {
|
|
106
109
|
this.emitWarning(
|
|
107
|
-
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
110
|
+
new Error('[Mpx json warning][native-loader][' + this.resource + ']: ' + msg)
|
|
108
111
|
)
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
const emitError = (msg) => {
|
|
112
115
|
this.emitError(
|
|
113
|
-
new Error('[native-loader][' + this.resource + ']: ' + msg)
|
|
116
|
+
new Error('[Mpx json error][native-loader][' + this.resource + ']: ' + msg)
|
|
114
117
|
)
|
|
115
118
|
}
|
|
116
119
|
let ctorType = pagesMap[resourcePath]
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
const runRules = require('../../run-rules')
|
|
2
2
|
const normalizeTest = require('../normalize-test')
|
|
3
3
|
const changeKey = require('../change-key')
|
|
4
|
-
const normalize = require('../../../utils/normalize')
|
|
5
4
|
const { capitalToHyphen } = require('../../../utils/string')
|
|
6
5
|
const { isOriginTag, isBuildInWebTag, isBuildInReactTag } = require('../../../utils/dom-tag-config')
|
|
7
|
-
|
|
8
|
-
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
9
|
-
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
6
|
+
const getBuildInTagComponent = require('../../../utils/get-build-tag-component')
|
|
10
7
|
|
|
11
8
|
module.exports = function getSpec ({ warn, error }) {
|
|
12
9
|
function print (mode, path, isError) {
|
|
@@ -46,28 +43,26 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
// 处理支付宝 componentPlaceholder 不支持 view、text 原生标签
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
// 将 placeholder 中使用的内建组件转化为 mpx-xxx, 并在 usingComponents 填充
|
|
47
|
+
function fixComponentPlaceholder (input, { mode }) {
|
|
48
|
+
if (!input.componentPlaceholder) return input
|
|
49
|
+
if (mode === 'ali') {
|
|
50
|
+
// 处理 驼峰转连字符
|
|
51
|
+
input = componentNameCapitalToHyphen('componentPlaceholder')(input)
|
|
52
|
+
}
|
|
52
53
|
const componentPlaceholder = input.componentPlaceholder
|
|
53
|
-
const usingComponents = input.usingComponents ||
|
|
54
|
+
const usingComponents = input.usingComponents || {}
|
|
54
55
|
for (const cph in componentPlaceholder) {
|
|
55
56
|
const cur = componentPlaceholder[cph]
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
compName = 'mpx-view'
|
|
62
|
-
compPath = mpxViewPath
|
|
63
|
-
break
|
|
64
|
-
case 'text':
|
|
65
|
-
compName = 'mpx-text'
|
|
66
|
-
compPath = mpxTextPath
|
|
67
|
-
}
|
|
68
|
-
usingComponents[compName] = compPath
|
|
69
|
-
componentPlaceholder[cph] = compName
|
|
57
|
+
const comp = getBuildInTagComponent(mode, cur)
|
|
58
|
+
if (!comp || usingComponents[cur]) continue
|
|
59
|
+
const { name, resource } = comp
|
|
60
|
+
usingComponents[name] = resource
|
|
61
|
+
componentPlaceholder[cph] = name
|
|
70
62
|
}
|
|
63
|
+
|
|
64
|
+
input.usingComponents = usingComponents
|
|
65
|
+
input.componentPlaceholder = componentPlaceholder
|
|
71
66
|
return input
|
|
72
67
|
}
|
|
73
68
|
|
|
@@ -172,7 +167,6 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
172
167
|
},
|
|
173
168
|
{
|
|
174
169
|
test: 'componentPlaceholder',
|
|
175
|
-
ali: aliComponentPlaceholderFallback,
|
|
176
170
|
swan: deletePath(),
|
|
177
171
|
jd: deletePath()
|
|
178
172
|
},
|
|
@@ -190,6 +184,13 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
190
184
|
ios: fixComponentName,
|
|
191
185
|
android: fixComponentName,
|
|
192
186
|
harmony: fixComponentName
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
ali: fixComponentPlaceholder,
|
|
190
|
+
web: fixComponentPlaceholder,
|
|
191
|
+
ios: fixComponentPlaceholder,
|
|
192
|
+
android: fixComponentPlaceholder,
|
|
193
|
+
harmony: fixComponentPlaceholder
|
|
193
194
|
}
|
|
194
195
|
]
|
|
195
196
|
|
|
@@ -454,12 +455,6 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
454
455
|
swan: getWindowRule(),
|
|
455
456
|
tt: getWindowRule(),
|
|
456
457
|
jd: getWindowRule()
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
web: fixComponentName,
|
|
460
|
-
ios: fixComponentName,
|
|
461
|
-
android: fixComponentName,
|
|
462
|
-
harmony: fixComponentName
|
|
463
458
|
}
|
|
464
459
|
]
|
|
465
460
|
}
|
|
@@ -315,7 +315,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
315
315
|
switch (prop) {
|
|
316
316
|
case bgPropMap.image: {
|
|
317
317
|
// background-image 支持背景图/渐变/css var
|
|
318
|
-
if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value)) {
|
|
318
|
+
if (cssVariableExp.test(value) || urlExp.test(value) || linearExp.test(value) || value === 'none') {
|
|
319
319
|
return { prop, value }
|
|
320
320
|
} else {
|
|
321
321
|
error(`Value of ${prop} in ${selector} selector only support value <url()> or <linear-gradient()>, received ${value}, please check again!`)
|
|
@@ -359,6 +359,13 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
359
359
|
error(`Property [${bgPropMap.all}] in ${selector} is abbreviated property and does not support CSS var`)
|
|
360
360
|
return false
|
|
361
361
|
}
|
|
362
|
+
// background: none
|
|
363
|
+
if (value === 'none') {
|
|
364
|
+
return [
|
|
365
|
+
{ prop: bgPropMap.image, value },
|
|
366
|
+
{ prop: bgPropMap.color, value: 'transparent' }
|
|
367
|
+
]
|
|
368
|
+
}
|
|
362
369
|
const bgMap = []
|
|
363
370
|
const values = parseValues(value)
|
|
364
371
|
values.forEach(item => {
|