@mpxjs/webpack-plugin 2.9.67 → 2.9.70-alpha.0
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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +51 -15
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +53 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- package/lib/resolver/AddModePlugin.js +8 -8
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -23
- package/lib/runtime/components/react/getInnerListeners.ts +36 -43
- package/lib/runtime/components/react/mpx-button.tsx +95 -43
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +302 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +81 -59
- package/lib/runtime/components/react/mpx-web-view.tsx +46 -19
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +3 -16
- package/lib/runtime/components/react/utils.tsx +98 -27
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +70 -42
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/tenon/index.js +117 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +203 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +126 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +9 -4
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
const loaderUtils = require('loader-utils')
|
|
2
|
+
const normalize = require('../utils/normalize')
|
|
3
|
+
const createHelpers = require('../helpers')
|
|
4
|
+
const tabBarContainerPath = normalize.lib('runtime/components/web/mpx-tab-bar-container.vue')
|
|
5
|
+
const tabBarPath = normalize.lib('runtime/components/web/mpx-tab-bar.vue')
|
|
6
|
+
const addQuery = require('../utils/add-query')
|
|
7
|
+
const parseRequest = require('../utils/parse-request')
|
|
8
|
+
const shallowStringify = require('../utils/shallow-stringify')
|
|
9
|
+
|
|
10
|
+
function stringifyRequest (loaderContext, request) {
|
|
11
|
+
return loaderUtils.stringifyRequest(loaderContext, request)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getAsyncChunkName (chunkName) {
|
|
15
|
+
if (chunkName && typeof chunkName !== 'boolean') {
|
|
16
|
+
return `/* webpackChunkName: "${chunkName}" */`
|
|
17
|
+
}
|
|
18
|
+
return ''
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderContext, jsonConfig }) {
|
|
22
|
+
const componentsMap = {}
|
|
23
|
+
if (localComponentsMap) {
|
|
24
|
+
Object.keys(localComponentsMap).forEach((componentName) => {
|
|
25
|
+
const componentCfg = localComponentsMap[componentName]
|
|
26
|
+
const componentRequest = stringifyRequest(loaderContext, componentCfg.resource)
|
|
27
|
+
if (componentCfg.async) {
|
|
28
|
+
// todo 暂时只处理局部注册的组件作为componentPlaceholder,暂不支持全局组件和原生组件,如使用了支持范围外的组件将不进行placeholder渲染及替换
|
|
29
|
+
if (jsonConfig.componentPlaceholder && jsonConfig.componentPlaceholder[componentName] && localComponentsMap[jsonConfig.componentPlaceholder[componentName]]) {
|
|
30
|
+
const placeholder = jsonConfig.componentPlaceholder[componentName]
|
|
31
|
+
const placeholderCfg = localComponentsMap[placeholder]
|
|
32
|
+
const placeholderRequest = stringifyRequest(loaderContext, placeholderCfg.resource)
|
|
33
|
+
if (placeholderCfg.async) {
|
|
34
|
+
loaderContext.emitWarning(
|
|
35
|
+
new Error(`[json processor][${loaderContext.resource}]: componentPlaceholder ${placeholder} should not be a async component, please check!`)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
componentsMap[componentName] = `function(){return {component: import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)}), loading: getComponent(require(${placeholderRequest}))}}`
|
|
39
|
+
} else {
|
|
40
|
+
componentsMap[componentName] = `function(){return import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(function(res){return getComponent(res)})}`
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
componentsMap[componentName] = `getComponent(require(${componentRequest}))`
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
if (builtInComponentsMap) {
|
|
48
|
+
Object.keys(builtInComponentsMap).forEach((componentName) => {
|
|
49
|
+
const componentCfg = builtInComponentsMap[componentName]
|
|
50
|
+
const componentRequest = stringifyRequest(loaderContext, componentCfg.resource)
|
|
51
|
+
componentsMap[componentName] = `getComponent(require(${componentRequest}), {__mpxBuiltIn: true})`
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
return componentsMap
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function buildPagesMap ({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBarStr, jsonConfig }) {
|
|
58
|
+
let globalTabBar = ''
|
|
59
|
+
let firstPage = ''
|
|
60
|
+
const pagesMap = {}
|
|
61
|
+
const tabBarPagesMap = {}
|
|
62
|
+
if (tabBar && tabBarMap) {
|
|
63
|
+
// 挂载tabBar组件
|
|
64
|
+
const tabBarRequest = stringifyRequest(loaderContext, addQuery(tabBar.custom ? './custom-tab-bar/index' : tabBarPath, { isComponent: true }))
|
|
65
|
+
tabBarPagesMap['mpx-tab-bar'] = `getComponent(require(${tabBarRequest}))`
|
|
66
|
+
// 挂载tabBar页面
|
|
67
|
+
Object.keys(tabBarMap).forEach((pagePath) => {
|
|
68
|
+
const pageCfg = localPagesMap[pagePath]
|
|
69
|
+
if (pageCfg) {
|
|
70
|
+
const pageRequest = stringifyRequest(loaderContext, pageCfg.resource)
|
|
71
|
+
if (pageCfg.async) {
|
|
72
|
+
tabBarPagesMap[pagePath] = `function(){return import(${getAsyncChunkName(pageCfg.async)}${pageRequest}).then(function(res) {return getComponent(res, {__mpxPageRoute: ${JSON.stringify(pagePath)}})})}`
|
|
73
|
+
} else {
|
|
74
|
+
tabBarPagesMap[pagePath] = `getComponent(require(${pageRequest}), {__mpxPageRoute: ${JSON.stringify(pagePath)}})`
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
loaderContext.emitWarning(
|
|
78
|
+
new Error(`[json processor][${loaderContext.resource}]: TabBar page path ${pagePath} is not exist in local page map, please check!`)
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
if (tabBarStr && tabBarPagesMap) {
|
|
84
|
+
globalTabBar += `
|
|
85
|
+
global.__tabBar = ${tabBarStr}
|
|
86
|
+
Vue.observable(global.__tabBar)
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
global.__tabBarPagesMap = ${shallowStringify(tabBarPagesMap)}\n`
|
|
89
|
+
}
|
|
90
|
+
Object.keys(localPagesMap).forEach((pagePath) => {
|
|
91
|
+
const pageCfg = localPagesMap[pagePath]
|
|
92
|
+
const pageRequest = stringifyRequest(loaderContext, pageCfg.resource)
|
|
93
|
+
if (tabBarMap && tabBarMap[pagePath]) {
|
|
94
|
+
pagesMap[pagePath] = `getComponent(require(${stringifyRequest(loaderContext, tabBarContainerPath)}), {__mpxBuiltIn: true})`
|
|
95
|
+
} else {
|
|
96
|
+
if (pageCfg.async) {
|
|
97
|
+
pagesMap[pagePath] = `function(){return import(${getAsyncChunkName(pageCfg.async)} ${pageRequest}).then(function(res){return getComponent(res, {__mpxPageRoute: ${JSON.stringify(pagePath)}})})}`
|
|
98
|
+
} else {
|
|
99
|
+
// 为了保持小程序中app->page->component的js执行顺序,所有的page和component都改为require引入
|
|
100
|
+
pagesMap[pagePath] = `getComponent(require(${pageRequest}), {__mpxPageRoute: ${JSON.stringify(pagePath)}})`
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (pagePath === jsonConfig.entryPagePath) {
|
|
105
|
+
firstPage = pagePath
|
|
106
|
+
}
|
|
107
|
+
if (!firstPage && pageCfg.isFirst) {
|
|
108
|
+
firstPage = pagePath
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
return {
|
|
112
|
+
pagesMap,
|
|
113
|
+
firstPage,
|
|
114
|
+
globalTabBar
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getRequireScript ({ script, ctorType, loaderContext }) {
|
|
119
|
+
let content = ' /** script content **/\n'
|
|
120
|
+
const { getRequire } = createHelpers(loaderContext)
|
|
121
|
+
const { resourcePath, queryObj } = parseRequest(loaderContext.resource)
|
|
122
|
+
const extraOptions = {
|
|
123
|
+
...script.src
|
|
124
|
+
? { ...queryObj, resourcePath }
|
|
125
|
+
: null,
|
|
126
|
+
ctorType,
|
|
127
|
+
lang: script.lang || 'js'
|
|
128
|
+
}
|
|
129
|
+
content += ` ${getRequire('script', script, extraOptions)}\n`
|
|
130
|
+
return content
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function buildGlobalParams ({
|
|
134
|
+
moduleId,
|
|
135
|
+
scriptSrcMode,
|
|
136
|
+
loaderContext,
|
|
137
|
+
isProduction,
|
|
138
|
+
jsonConfig,
|
|
139
|
+
webConfig,
|
|
140
|
+
isMain,
|
|
141
|
+
globalTabBar,
|
|
142
|
+
hasApp
|
|
143
|
+
}) {
|
|
144
|
+
let content = ''
|
|
145
|
+
if (isMain) {
|
|
146
|
+
content += `
|
|
147
|
+
global.getApp = function () {}
|
|
148
|
+
global.getCurrentPages = function () {
|
|
149
|
+
if (!(typeof window !== 'undefined')) {
|
|
150
|
+
console.error('[Mpx runtime error]: Dangerous API! global.getCurrentPages is running in non browser environment, It may cause some problems, please use this method with caution')
|
|
151
|
+
}
|
|
152
|
+
var router = global.__mpxRouter
|
|
153
|
+
if (!router) return []
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
return (router.lastStack || router.stack).map(function (item) {
|
|
156
|
+
var page
|
|
157
|
+
var vnode = item.vnode
|
|
158
|
+
if (vnode && vnode.componentInstance) {
|
|
159
|
+
page = vnode.tag.endsWith('mpx-tab-bar-container') ? vnode.componentInstance.$refs.tabBarPage : vnode.componentInstance
|
|
160
|
+
}
|
|
161
|
+
return page || { route: item.path.slice(1) }
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
global.__networkTimeout = ${JSON.stringify(jsonConfig.networkTimeout)}
|
|
165
|
+
global.__mpxGenericsMap = {}
|
|
166
|
+
global.__mpxOptionsMap = {}
|
|
167
|
+
global.__style = ${JSON.stringify(jsonConfig.style || 'v1')}
|
|
168
|
+
global.__mpxPageConfig = ${JSON.stringify(jsonConfig.window)}
|
|
169
|
+
global.__mpxTransRpxFn = ${webConfig.transRpxFn}\n`
|
|
170
|
+
if (globalTabBar) {
|
|
171
|
+
content += globalTabBar
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
if (!hasApp) {
|
|
175
|
+
content += ' global.__mpxGenericsMap = global.__mpxGenericsMap || {}\n'
|
|
176
|
+
content += ' global.__mpxOptionsMap = global.__mpxOptionsMap || {}\n'
|
|
177
|
+
content += ` global.__mpxTransRpxFn = ${webConfig.transRpxFn}\n`
|
|
178
|
+
}
|
|
179
|
+
content += ` global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
180
|
+
content += ` global.currentSrcMode = ${JSON.stringify(scriptSrcMode)}\n`
|
|
181
|
+
content += ` global.currentInject = ${JSON.stringify({ moduleId })}\n`
|
|
182
|
+
if (!isProduction) {
|
|
183
|
+
content += ` global.currentResource = ${JSON.stringify(loaderContext.resourcePath)}\n`
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return content
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function buildI18n ({ i18n, loaderContext }) {
|
|
190
|
+
let i18nContent = ''
|
|
191
|
+
const i18nObj = Object.assign({}, i18n)
|
|
192
|
+
i18nContent += `
|
|
193
|
+
import VueI18n from 'vue-i18n'
|
|
194
|
+
import { createI18n } from 'vue-i18n-bridge'
|
|
195
|
+
Vue.use(VueI18n , { bridge: true })\n`
|
|
196
|
+
const requestObj = {}
|
|
197
|
+
const i18nKeys = ['messages', 'dateTimeFormats', 'numberFormats']
|
|
198
|
+
i18nKeys.forEach((key) => {
|
|
199
|
+
if (i18nObj[`${key}Path`]) {
|
|
200
|
+
requestObj[key] = stringifyRequest(loaderContext, i18nObj[`${key}Path`])
|
|
201
|
+
delete i18nObj[`${key}Path`]
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
i18nContent += ` var i18nCfg = ${JSON.stringify(i18nObj)}\n`
|
|
205
|
+
Object.keys(requestObj).forEach((key) => {
|
|
206
|
+
i18nContent += ` i18nCfg.${key} = require(${requestObj[key]})\n`
|
|
207
|
+
})
|
|
208
|
+
i18nContent += `
|
|
209
|
+
i18nCfg.legacy = false
|
|
210
|
+
var i18n = createI18n(i18nCfg, VueI18n)
|
|
211
|
+
Vue.use(i18n)
|
|
212
|
+
Mpx.i18n = i18n\n`
|
|
213
|
+
return i18nContent
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module.exports = {
|
|
217
|
+
buildPagesMap,
|
|
218
|
+
buildComponentsMap,
|
|
219
|
+
getRequireScript,
|
|
220
|
+
buildGlobalParams,
|
|
221
|
+
stringifyRequest,
|
|
222
|
+
buildI18n
|
|
223
|
+
}
|
package/lib/utils/env.js
CHANGED
|
@@ -6,12 +6,17 @@ function isWeb (mode) {
|
|
|
6
6
|
return mode === 'web'
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function isTenon (mode) {
|
|
10
|
+
return mode === 'tenon'
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
function isMiniProgram (mode) {
|
|
10
|
-
return !isWeb(mode) && !isReact(mode)
|
|
14
|
+
return !isWeb(mode) && !isReact(mode) && !isTenon(mode)
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
module.exports = {
|
|
14
18
|
isWeb,
|
|
15
19
|
isReact,
|
|
20
|
+
isTenon,
|
|
16
21
|
isMiniProgram
|
|
17
22
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function getRelativePath (source, target) {
|
|
2
|
+
// make sure source and target are absolute path
|
|
3
|
+
/^\//.test(source) || (source = '/' + source);
|
|
4
|
+
/^\//.test(target) || (target = '/' + target)
|
|
5
|
+
|
|
6
|
+
source = source && source.replace(/\/[^/]*$/, '') // get dirname
|
|
7
|
+
// check if source or target is root path
|
|
8
|
+
const sourceArr = source.split('/').filter((item, index) => index !== 0 && !!item)
|
|
9
|
+
const targetArr = target.split('/').filter((item, index) => index !== 0 && !!item)
|
|
10
|
+
let i = 0
|
|
11
|
+
while (sourceArr[i] === targetArr[i] && i < sourceArr.length && i < targetArr.length) {
|
|
12
|
+
i++
|
|
13
|
+
}
|
|
14
|
+
let relativePath = ''
|
|
15
|
+
for (let j = 0; j < sourceArr.length - i; j++) {
|
|
16
|
+
relativePath += '../'
|
|
17
|
+
}
|
|
18
|
+
relativePath += targetArr.slice(i).join('/')
|
|
19
|
+
if (relativePath[0] !== '.') relativePath = './' + relativePath
|
|
20
|
+
return relativePath
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
getRelativePath
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.70-alpha.0",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -27,8 +27,11 @@
|
|
|
27
27
|
"@better-scroll/slide": "^2.5.1",
|
|
28
28
|
"@better-scroll/wheel": "^2.5.1",
|
|
29
29
|
"@better-scroll/zoom": "^2.5.1",
|
|
30
|
+
"@hummer/tenon-dev-server-webpack-plugin": "0.0.2",
|
|
31
|
+
"@hummer/tenon-loader": "^1.2.0",
|
|
32
|
+
"@hummer/tenon-style-loader": "^0.2.0",
|
|
30
33
|
"@mpxjs/template-engine": "^2.8.7",
|
|
31
|
-
"@mpxjs/utils": "
|
|
34
|
+
"@mpxjs/utils": ">=2.9.69-alpha",
|
|
32
35
|
"acorn": "^8.11.3",
|
|
33
36
|
"acorn-walk": "^7.2.0",
|
|
34
37
|
"async": "^2.6.0",
|
|
@@ -82,7 +85,8 @@
|
|
|
82
85
|
},
|
|
83
86
|
"devDependencies": {
|
|
84
87
|
"@ant-design/react-native": "^5.2.2",
|
|
85
|
-
"@
|
|
88
|
+
"@d11/react-native-fast-image": "^8.6.12",
|
|
89
|
+
"@mpxjs/api-proxy": "^2.9.69",
|
|
86
90
|
"@types/babel-traverse": "^6.25.4",
|
|
87
91
|
"@types/babel-types": "^7.0.4",
|
|
88
92
|
"@types/react": "^18.2.79",
|
|
@@ -91,11 +95,12 @@
|
|
|
91
95
|
"react-native-linear-gradient": "^2.8.3",
|
|
92
96
|
"react-native-reanimated": "^3.15.2",
|
|
93
97
|
"react-native-safe-area-context": "^4.12.0",
|
|
98
|
+
"react-native-svg": "^15.8.0",
|
|
94
99
|
"react-native-webview": "^13.12.2",
|
|
95
100
|
"rimraf": "^6.0.1"
|
|
96
101
|
},
|
|
97
102
|
"engines": {
|
|
98
103
|
"node": ">=14.14.0"
|
|
99
104
|
},
|
|
100
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "2d37697869b9bdda3efab92dda8c910b68fd05c0"
|
|
101
106
|
}
|