@mpxjs/webpack-plugin 2.10.15 → 2.10.16-beta.3

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.
Files changed (89) hide show
  1. package/lib/dependencies/AppEntryDependency.js +2 -2
  2. package/lib/dependencies/DynamicEntryDependency.js +1 -1
  3. package/lib/dependencies/ImportDependency.js +102 -0
  4. package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
  5. package/lib/dependencies/ResolveDependency.js +1 -1
  6. package/lib/{retry-runtime-module.js → dependencies/RetryRuntimeModule.js} +1 -1
  7. package/lib/helpers.js +2 -0
  8. package/lib/index.js +51 -25
  9. package/lib/json-compiler/helper.js +72 -2
  10. package/lib/json-compiler/index.js +14 -54
  11. package/lib/json-compiler/plugin.js +2 -2
  12. package/lib/loader.js +6 -2
  13. package/lib/native-loader.js +6 -3
  14. package/lib/platform/json/wx/index.js +24 -29
  15. package/lib/platform/style/wx/index.js +8 -1
  16. package/lib/platform/template/wx/component-config/button.js +12 -3
  17. package/lib/platform/template/wx/component-config/camera.js +12 -0
  18. package/lib/platform/template/wx/component-config/component.js +31 -33
  19. package/lib/platform/template/wx/component-config/slider.js +12 -0
  20. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  21. package/lib/react/processJSON.js +39 -71
  22. package/lib/react/processStyles.js +3 -2
  23. package/lib/react/processTemplate.js +6 -6
  24. package/lib/react/script-helper.js +6 -16
  25. package/lib/react/style-helper.js +10 -2
  26. package/lib/resolver/AddEnvPlugin.js +13 -0
  27. package/lib/resolver/AddModePlugin.js +18 -0
  28. package/lib/runtime/components/react/context.ts +2 -0
  29. package/lib/runtime/components/react/dist/context.js +1 -0
  30. package/lib/runtime/components/react/dist/mpx-camera.jsx +102 -0
  31. package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
  32. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +19 -4
  33. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -2
  34. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +9 -6
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
  36. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
  37. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  38. package/lib/runtime/components/react/dist/mpx-progress.jsx +26 -22
  39. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
  40. package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
  41. package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
  42. package/lib/runtime/components/react/dist/mpx-view.jsx +8 -11
  43. package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
  44. package/lib/runtime/components/react/dist/utils.jsx +16 -6
  45. package/lib/runtime/components/react/mpx-camera.tsx +167 -0
  46. package/lib/runtime/components/react/mpx-image.tsx +89 -42
  47. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -4
  48. package/lib/runtime/components/react/mpx-picker-view/index.tsx +4 -1
  49. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +19 -8
  50. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
  51. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
  52. package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
  53. package/lib/runtime/components/react/mpx-progress.tsx +26 -24
  54. package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
  55. package/lib/runtime/components/react/mpx-slider.tsx +444 -0
  56. package/lib/runtime/components/react/mpx-text.tsx +38 -5
  57. package/lib/runtime/components/react/mpx-view.tsx +8 -11
  58. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  59. package/lib/runtime/components/react/utils.tsx +15 -6
  60. package/lib/runtime/components/web/mpx-input.vue +1 -1
  61. package/lib/runtime/components/web/mpx-scroll-view.vue +7 -1
  62. package/lib/runtime/components/web/mpx-video.vue +12 -1
  63. package/lib/runtime/optionProcessor.js +3 -1
  64. package/lib/runtime/optionProcessorReact.js +4 -2
  65. package/lib/script-setup-compiler/index.js +2 -2
  66. package/lib/style-compiler/index.js +3 -2
  67. package/lib/style-compiler/load-postcss-config.js +1 -1
  68. package/lib/style-compiler/plugins/trans-special.js +10 -2
  69. package/lib/style-compiler/strip-conditional-loader.js +155 -15
  70. package/lib/template-compiler/compiler.js +262 -61
  71. package/lib/template-compiler/gen-node-react.js +18 -6
  72. package/lib/template-compiler/index.js +6 -4
  73. package/lib/template-compiler/parse-exps.js +1 -1
  74. package/lib/utils/chain-assign.js +47 -0
  75. package/lib/utils/check-core-version-match.js +75 -15
  76. package/lib/utils/const.js +2 -1
  77. package/lib/utils/dom-tag-config.js +1 -1
  78. package/lib/utils/env.js +6 -1
  79. package/lib/utils/get-build-tag-component.js +35 -0
  80. package/lib/utils/pre-process-json.js +5 -0
  81. package/lib/web/processJSON.js +44 -16
  82. package/lib/web/processScript.js +1 -1
  83. package/lib/web/processTemplate.js +4 -4
  84. package/lib/web/script-helper.js +19 -9
  85. package/lib/wxs/pre-loader.js +6 -6
  86. package/lib/wxss/loader.js +1 -9
  87. package/package.json +14 -5
  88. package/LICENSE +0 -433
  89. package/lib/dependencies/ImportDependencyTemplate.js +0 -50
@@ -1,22 +1,82 @@
1
- const coreVersion = require('@mpxjs/core/package.json').version
2
- const utilsVersion = require('@mpxjs/utils/package.json').version
3
- const corePath = require.resolve('@mpxjs/core')
4
- const utilsPath = require.resolve('@mpxjs/utils')
5
- const semverLt = require('semver/functions/lt')
1
+ const semverSatisfies = require('semver/functions/satisfies')
2
+ const semverCoerce = require('semver/functions/coerce')
6
3
 
7
- const leastCoreVersion = '2.8.59'
8
- const leastUtilsVersion = '2.8.59'
4
+ // 定义包之间的依赖关系和最低版本要求
5
+ const PACKAGE_DEPENDENCIES = {
6
+ '@mpxjs/webpack-plugin': {
7
+ '@mpxjs/core': '^2.10.15 || ^2.10.15-beta.1',
8
+ '@mpxjs/utils': '^2.10.13 || ^2.10.13-beta.1',
9
+ '@mpxjs/api-proxy': '^2.10.15 || ^2.10.15-beta.1'
10
+ }
11
+ }
12
+
13
+ function getPackageVersion (packageName) {
14
+ try {
15
+ return require(`${packageName}/package.json`).version
16
+ } catch (e) {
17
+ console.warn(`无法获取 ${packageName} 的版本信息: ${e.message}`)
18
+ return null
19
+ }
20
+ }
21
+
22
+ function checkVersionSatisfies (version, requiredVersion) {
23
+ try {
24
+ const normalizedVersion = semverCoerce(version).version
25
+ return semverSatisfies(normalizedVersion, requiredVersion)
26
+ } catch (e) {
27
+ console.warn(`版本检查失败: ${e.message}`)
28
+ return false
29
+ }
30
+ }
31
+
32
+ function checkPackageDependencies (packageName) {
33
+ const dependencies = PACKAGE_DEPENDENCIES[packageName]
34
+ if (!dependencies) return []
35
+
36
+ const results = []
37
+
38
+ for (const depName in dependencies) {
39
+ const requiredVersion = dependencies[depName]
40
+ const actualVersion = getPackageVersion(depName)
41
+
42
+ if (!actualVersion) {
43
+ results.push({
44
+ dependency: depName,
45
+ required: requiredVersion,
46
+ actual: null,
47
+ compatible: false,
48
+ error: `无法获取 ${depName} 的版本信息`
49
+ })
50
+ continue
51
+ }
52
+
53
+ const isCompatible = checkVersionSatisfies(actualVersion, requiredVersion)
54
+ results.push({
55
+ dependency: depName,
56
+ required: requiredVersion,
57
+ actual: actualVersion,
58
+ compatible: isCompatible
59
+ })
60
+ }
61
+
62
+ return results
63
+ }
9
64
 
10
- function compare (version, leastVersion, npmName, npmPath) {
11
- if (semverLt(version, leastVersion)) {
65
+ function checkVersionCompatibility () {
66
+ const pluginResults = checkPackageDependencies('@mpxjs/webpack-plugin')
67
+ const incompatibleResults = pluginResults.filter(result => !result.compatible)
68
+ if (incompatibleResults.length > 0) {
69
+ const errorMessages = incompatibleResults.map(result => {
70
+ if (!result.actual) {
71
+ return ` - ${result.error || `${result.dependency} 未安装`}`
72
+ }
73
+ return ` - ${result.dependency}@${result.actual} 不满足所需版本 ${result.required}`
74
+ })
12
75
  throw new Error(
13
- `${npmName} packages version mismatch:
14
- -${npmName}@${version}(${npmPath})
15
- This may cause things to work incorrectly, Make sure the usage version is greater than ${leastVersion}.
16
- `
76
+ `检测到 @mpxjs 包版本不兼容问题:\n${errorMessages.join('\n')}\n\n` +
77
+ '这可能导致编译或运行异常。请确保所有 @mpxjs 相关包的版本兼容,建议使用相同版本。'
17
78
  )
18
79
  }
19
80
  }
20
81
 
21
- compare(coreVersion, leastCoreVersion, '@mpxjs/core', corePath)
22
- compare(utilsVersion, leastUtilsVersion, '@mpxjs/utils', utilsPath)
82
+ module.exports = checkVersionCompatibility
@@ -6,5 +6,6 @@ module.exports = {
6
6
  JSON_JS_EXT: '.json.js',
7
7
  MPX_ROOT_VIEW: 'mpx-root-view', // 根节点类名
8
8
  MPX_APP_MODULE_ID: 'mpx-app-scope', // app文件moduleId
9
- PARENT_MODULE_ID: '__pid'
9
+ PARENT_MODULE_ID: '__pid',
10
+ MPX_TAG_PAGE_SELECTOR: 'mpx-page'
10
11
  }
@@ -91,7 +91,7 @@ const isBuildInReactTag = makeMap(
91
91
  'mpx-movable-area,mpx-label,mpx-keyboard-avoiding-view,mpx-input,mpx-inline-text,' +
92
92
  'mpx-image,mpx-form,mpx-checkbox,mpx-checkbox-group,mpx-button,' +
93
93
  'mpx-rich-text,mpx-portal,mpx-popup,mpx-picker-view-column,mpx-picker-view,mpx-picker,' +
94
- 'mpx-icon,mpx-canvas'
94
+ 'mpx-icon,mpx-canvas,mpx-camera'
95
95
  )
96
96
 
97
97
  const isSpace = makeMap('ensp,emsp,nbsp')
package/lib/utils/env.js CHANGED
@@ -10,8 +10,13 @@ function isMiniProgram (mode) {
10
10
  return !isWeb(mode) && !isReact(mode)
11
11
  }
12
12
 
13
+ function isNoMode (mode) {
14
+ return mode === 'noMode'
15
+ }
16
+
13
17
  module.exports = {
14
18
  isWeb,
15
19
  isReact,
16
- isMiniProgram
20
+ isMiniProgram,
21
+ isNoMode
17
22
  }
@@ -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
+ }
@@ -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)
@@ -37,23 +37,38 @@ module.exports = function (jsonContent, {
37
37
 
38
38
  const emitWarning = (msg) => {
39
39
  loaderContext.emitWarning(
40
- new Error('[json processor][' + loaderContext.resource + ']: ' + msg)
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 compiler][' + loaderContext.resource + ']: ' + msg)
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(new Error(`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!`))
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, { resource, outputPath } = {}, { tarRoot } = {}) => {
308
+ processComponent(component, context, {}, (err, entry = {}, { tarRoot, placeholder, resourcePath } = {}) => {
292
309
  if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
293
- const { resourcePath, queryObj } = parseRequest(resource)
294
- componentsMap[resourcePath] = outputPath
295
- loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
296
- localComponentsMap[name] = {
297
- resource: addQuery(resource, {
298
- isComponent: true,
299
- outputPath
300
- }),
301
- async: queryObj.async || tarRoot
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
- }, callback)
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
  }
@@ -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('[mpx loader][' + loaderContext.resource + ']: ' + 'template content must be inline in .mpx files!'))
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('[mpx loader][' + loaderContext.resource + ']: ' + 'template lang is not supported in trans web mode temporarily, we will support it in the future!'))
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 compiler][' + loaderContext.resource + ']: ' + msg)
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 compiler][' + loaderContext.resource + ']: ' + msg)
73
+ new Error('[Mpx template error][' + loaderContext.resource + ']: ' + msg)
74
74
  )
75
75
  }
76
76
  const { root, meta } = templateCompiler.parse(template.content, {
@@ -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
- // todo 暂时只处理局部注册的组件作为componentPlaceholder,暂不支持全局组件和原生组件,如使用了支持范围外的组件将不进行placeholder渲染及替换
29
- if (jsonConfig.componentPlaceholder && jsonConfig.componentPlaceholder[componentName] && localComponentsMap[jsonConfig.componentPlaceholder[componentName]]) {
30
- const placeholder = jsonConfig.componentPlaceholder[componentName]
29
+ const placeholder = jsonConfig.componentPlaceholder && jsonConfig.componentPlaceholder[componentName]
30
+ if (placeholder) {
31
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!`)
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 processor][${loaderContext.resource}]: TabBar page path ${pagePath} is not exist in local page map, please check!`)
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
  })
@@ -4,6 +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 chainAssign = require('../utils/chain-assign')
7
8
  const parseQuery = require('loader-utils').parseQuery
8
9
 
9
10
  module.exports = function (content) {
@@ -30,8 +31,7 @@ module.exports = function (content) {
30
31
  ' __mpx_args__[i] = arguments[i];\n' +
31
32
  '}'
32
33
  ).program.body
33
- // todo Object.assign可能会覆盖,未来存在非预期的覆盖case时需要改进处理
34
- Object.assign(visitor, {
34
+ chainAssign(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
- Object.assign(visitor, {
69
+ chainAssign(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
- Object.assign(visitor, {
84
+ chainAssign(visitor, {
85
85
  MemberExpression (path) {
86
86
  const property = path.node.property
87
87
  if (
@@ -96,11 +96,11 @@ module.exports = function (content) {
96
96
  }
97
97
 
98
98
  if (!module.wxs) {
99
- Object.assign(visitor, {
99
+ chainAssign(visitor, {
100
100
  MemberExpression (path) {
101
101
  const property = path.node.property
102
102
  if (
103
- (property.name === 'constructor' || property.value === 'constructor') &&
103
+ property && (property.name === 'constructor' || property.value === 'constructor') &&
104
104
  !(t.isMemberExpression(path.parent) && path.parentKey === 'object')
105
105
  ) {
106
106
  path.replaceWith(t.memberExpression(path.node, t.identifier('name')))
@@ -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.15",
3
+ "version": "2.10.16-beta.3",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -21,6 +21,7 @@
21
21
  "@babel/traverse": "^7.16.0",
22
22
  "@babel/types": "^7.16.0",
23
23
  "@better-scroll/core": "^2.5.1",
24
+ "@better-scroll/mouse-wheel": "^2.5.1",
24
25
  "@better-scroll/movable": "^2.5.1",
25
26
  "@better-scroll/observe-dom": "^2.5.1",
26
27
  "@better-scroll/pull-down": "^2.5.1",
@@ -28,7 +29,7 @@
28
29
  "@better-scroll/wheel": "^2.5.1",
29
30
  "@better-scroll/zoom": "^2.5.1",
30
31
  "@mpxjs/template-engine": "^2.8.7",
31
- "@mpxjs/utils": "^2.10.13",
32
+ "@mpxjs/utils": "^2.10.16",
32
33
  "acorn": "^8.11.3",
33
34
  "acorn-walk": "^7.2.0",
34
35
  "async": "^2.6.0",
@@ -50,6 +51,7 @@
50
51
  "mime": "^2.2.2",
51
52
  "object-assign": "^4.1.1",
52
53
  "postcss": "^8.4.5",
54
+ "postcss-import": "^16.1.1",
53
55
  "postcss-load-config": "^3.1.1",
54
56
  "postcss-modules-extract-imports": "^3.0.0",
55
57
  "postcss-modules-local-by-default": "^4.0.0",
@@ -62,6 +64,9 @@
62
64
  "webpack-virtual-modules": "^0.6.0"
63
65
  },
64
66
  "peerDependencies": {
67
+ "postcss-less": "^6.0.0",
68
+ "postcss-scss": "^4.0.9",
69
+ "postcss-styl": "^0.12.3",
65
70
  "webpack": "^5.75.0"
66
71
  },
67
72
  "publishConfig": {
@@ -77,16 +82,19 @@
77
82
  "url": "https://github.com/didi/mpx/issues"
78
83
  },
79
84
  "scripts": {
80
- "test": "jest",
85
+ "test": "jest --passWithNoTests",
81
86
  "copy-icons": "cp -r ./lib/runtime/components/react/mpx-icon/icons ./lib/runtime/components/react/dist/mpx-icon/icons",
82
87
  "build": "rimraf ./lib/runtime/components/react/dist && tsc && npm run copy-icons"
83
88
  },
84
89
  "devDependencies": {
85
90
  "@d11/react-native-fast-image": "^8.6.12",
86
- "@mpxjs/api-proxy": "^2.10.15",
91
+ "@mpxjs/api-proxy": "^2.10.16",
87
92
  "@types/babel-traverse": "^6.25.4",
88
93
  "@types/babel-types": "^7.0.4",
94
+ "@types/glob": "^8.1.0",
95
+ "@types/postcss-import": "^14.0.3",
89
96
  "@types/react": "^18.2.79",
97
+ "glob": "^11.0.2",
90
98
  "react-native": "^0.74.5",
91
99
  "react-native-gesture-handler": "^2.18.1",
92
100
  "react-native-linear-gradient": "^2.8.3",
@@ -94,11 +102,12 @@
94
102
  "react-native-safe-area-context": "^4.12.0",
95
103
  "react-native-svg": "^15.8.0",
96
104
  "react-native-video": "^6.9.0",
105
+ "react-native-vision-camera": "^4.7.2",
97
106
  "react-native-webview": "^13.12.2",
98
107
  "rimraf": "^6.0.1"
99
108
  },
100
109
  "engines": {
101
110
  "node": ">=14.14.0"
102
111
  },
103
- "gitHead": "4ea4a54f55aa938ad139e080827cffbbf7bb82db"
112
+ "gitHead": "2d37697869b9bdda3efab92dda8c910b68fd05c0"
104
113
  }