@mpxjs/webpack-plugin 2.10.15-prelease.1 → 2.10.16-beta.2
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 +6 -2
- 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/camera.js +12 -0
- package/lib/platform/template/wx/component-config/component.js +31 -33
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processJSON.js +39 -71
- package/lib/react/processStyles.js +3 -2
- package/lib/react/processTemplate.js +6 -6
- package/lib/react/script-helper.js +6 -16
- package/lib/react/style-helper.js +10 -2
- package/lib/runtime/components/react/context.ts +2 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +102 -0
- package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +19 -4
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +9 -6
- 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.jsx +20 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
- package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +16 -6
- package/lib/runtime/components/react/mpx-camera.tsx +167 -0
- package/lib/runtime/components/react/mpx-image.tsx +89 -42
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -4
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +4 -1
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +19 -8
- 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-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 +1 -1
- package/lib/runtime/components/react/utils.tsx +15 -6
- package/lib/runtime/components/web/mpx-input.vue +0 -14
- 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 +155 -15
- package/lib/template-compiler/compiler.js +252 -55
- 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 +1 -1
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-build-tag-component.js +35 -0
- package/lib/utils/pre-process-json.js +5 -0
- package/lib/web/processJSON.js +44 -16
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +4 -4
- package/lib/web/script-helper.js +19 -9
- package/lib/wxss/loader.js +1 -9
- package/package.json +12 -4
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)},
|
|
@@ -51,10 +51,10 @@ module.exports = function (template, {
|
|
|
51
51
|
if (template) {
|
|
52
52
|
// 由于远端src template资源引用的相对路径可能发生变化,暂时不支持。
|
|
53
53
|
if (template.src) {
|
|
54
|
-
return callback(new Error('[
|
|
54
|
+
return callback(new Error('[Mpx template error][' + loaderContext.resource + ']: ' + 'template content must be inline in .mpx files!'))
|
|
55
55
|
}
|
|
56
56
|
if (template.lang) {
|
|
57
|
-
return callback(new Error('[
|
|
57
|
+
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
58
|
}
|
|
59
59
|
|
|
60
60
|
output += genComponentTag(template, (template) => {
|
|
@@ -65,12 +65,12 @@ module.exports = function (template, {
|
|
|
65
65
|
const templateSrcMode = template.mode || srcMode
|
|
66
66
|
const warn = (msg) => {
|
|
67
67
|
loaderContext.emitWarning(
|
|
68
|
-
new Error('[template
|
|
68
|
+
new Error('[Mpx template error][' + loaderContext.resource + ']: ' + msg)
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
const error = (msg) => {
|
|
72
72
|
loaderContext.emitError(
|
|
73
|
-
new Error('[template
|
|
73
|
+
new Error('[Mpx template error][' + loaderContext.resource + ']: ' + msg)
|
|
74
74
|
)
|
|
75
75
|
}
|
|
76
76
|
const { root, meta } = templateCompiler.parse(template.content, {
|
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/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.16-beta.2",
|
|
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.16",
|
|
33
33
|
"acorn": "^8.11.3",
|
|
34
34
|
"acorn-walk": "^7.2.0",
|
|
35
35
|
"async": "^2.6.0",
|
|
@@ -51,6 +51,7 @@
|
|
|
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",
|
|
54
55
|
"postcss-load-config": "^3.1.1",
|
|
55
56
|
"postcss-modules-extract-imports": "^3.0.0",
|
|
56
57
|
"postcss-modules-local-by-default": "^4.0.0",
|
|
@@ -63,6 +64,9 @@
|
|
|
63
64
|
"webpack-virtual-modules": "^0.6.0"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
67
|
+
"postcss-less": "^6.0.0",
|
|
68
|
+
"postcss-scss": "^4.0.9",
|
|
69
|
+
"postcss-styl": "^0.12.3",
|
|
66
70
|
"webpack": "^5.75.0"
|
|
67
71
|
},
|
|
68
72
|
"publishConfig": {
|
|
@@ -78,16 +82,19 @@
|
|
|
78
82
|
"url": "https://github.com/didi/mpx/issues"
|
|
79
83
|
},
|
|
80
84
|
"scripts": {
|
|
81
|
-
"test": "jest",
|
|
85
|
+
"test": "jest --passWithNoTests",
|
|
82
86
|
"copy-icons": "cp -r ./lib/runtime/components/react/mpx-icon/icons ./lib/runtime/components/react/dist/mpx-icon/icons",
|
|
83
87
|
"build": "rimraf ./lib/runtime/components/react/dist && tsc && npm run copy-icons"
|
|
84
88
|
},
|
|
85
89
|
"devDependencies": {
|
|
86
90
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
87
|
-
"@mpxjs/api-proxy": "^2.10.
|
|
91
|
+
"@mpxjs/api-proxy": "^2.10.16",
|
|
88
92
|
"@types/babel-traverse": "^6.25.4",
|
|
89
93
|
"@types/babel-types": "^7.0.4",
|
|
94
|
+
"@types/glob": "^8.1.0",
|
|
95
|
+
"@types/postcss-import": "^14.0.3",
|
|
90
96
|
"@types/react": "^18.2.79",
|
|
97
|
+
"glob": "^11.0.2",
|
|
91
98
|
"react-native": "^0.74.5",
|
|
92
99
|
"react-native-gesture-handler": "^2.18.1",
|
|
93
100
|
"react-native-linear-gradient": "^2.8.3",
|
|
@@ -95,6 +102,7 @@
|
|
|
95
102
|
"react-native-safe-area-context": "^4.12.0",
|
|
96
103
|
"react-native-svg": "^15.8.0",
|
|
97
104
|
"react-native-video": "^6.9.0",
|
|
105
|
+
"react-native-vision-camera": "^4.7.2",
|
|
98
106
|
"react-native-webview": "^13.12.2",
|
|
99
107
|
"rimraf": "^6.0.1"
|
|
100
108
|
},
|