@mpxjs/webpack-plugin 2.10.15-4 → 2.10.15-prelease.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.
Files changed (45) hide show
  1. package/lib/dependencies/DynamicEntryDependency.js +1 -1
  2. package/lib/dependencies/ImportDependency.js +102 -0
  3. package/lib/{retry-runtime-module.js → dependencies/RetryRuntimeModule.js} +1 -1
  4. package/lib/index.js +13 -15
  5. package/lib/platform/template/wx/component-config/progress.js +12 -0
  6. package/lib/platform/template/wx/component-config/slider.js +12 -0
  7. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  8. package/lib/platform/template/wx/index.js +3 -1
  9. package/lib/resolver/AddEnvPlugin.js +13 -0
  10. package/lib/resolver/AddModePlugin.js +18 -0
  11. package/lib/runtime/components/react/dist/getInnerListeners.js +35 -21
  12. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +102 -34
  13. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +3 -5
  14. package/lib/runtime/components/react/dist/mpx-progress.jsx +163 -0
  15. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +51 -9
  16. package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
  17. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -16
  18. package/lib/runtime/components/react/dist/mpx-view.jsx +7 -10
  19. package/lib/runtime/components/react/dist/mpx-web-view.jsx +20 -1
  20. package/lib/runtime/components/react/getInnerListeners.ts +41 -22
  21. package/lib/runtime/components/react/mpx-movable-view.tsx +156 -48
  22. package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +4 -8
  23. package/lib/runtime/components/react/mpx-progress.tsx +259 -0
  24. package/lib/runtime/components/react/mpx-scroll-view.tsx +54 -9
  25. package/lib/runtime/components/react/mpx-slider.tsx +444 -0
  26. package/lib/runtime/components/react/mpx-swiper.tsx +9 -16
  27. package/lib/runtime/components/react/mpx-view.tsx +7 -10
  28. package/lib/runtime/components/react/mpx-web-view.tsx +22 -1
  29. package/lib/runtime/components/react/types/getInnerListeners.d.ts +7 -2
  30. package/lib/runtime/components/web/mpx-input.vue +14 -0
  31. package/lib/runtime/components/web/mpx-movable-area.vue +43 -19
  32. package/lib/runtime/components/web/mpx-movable-view.vue +93 -3
  33. package/lib/runtime/components/web/mpx-scroll-view.vue +7 -1
  34. package/lib/runtime/components/web/mpx-swiper.vue +1 -2
  35. package/lib/runtime/components/web/mpx-video.vue +12 -1
  36. package/lib/runtime/components/web/mpx-web-view.vue +3 -3
  37. package/lib/runtime/optionProcessor.js +3 -1
  38. package/lib/runtime/optionProcessorReact.js +4 -2
  39. package/lib/template-compiler/compiler.js +69 -35
  40. package/lib/utils/chain-assign.js +47 -0
  41. package/lib/utils/check-core-version-match.js +75 -15
  42. package/lib/wxs/pre-loader.js +5 -5
  43. package/lib/wxss/utils.js +1 -1
  44. package/package.json +3 -2
  45. package/lib/dependencies/ImportDependencyTemplate.js +0 -50
@@ -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,7 +96,7 @@ 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 (
package/lib/wxss/utils.js CHANGED
@@ -1052,7 +1052,7 @@ function getModuleCode (
1052
1052
  `@import url(${url});`
1053
1053
  )}${printedParam.length > 0 ? `, ${printedParam}` : ''}]);\n`
1054
1054
  } else {
1055
- // 符合css后缀名的文件经过mpx处理后会带上相应的后缀防止使用 WebPack 的默认解析规则,此时 require/import 相应路径时,导出的不是一段 css 代码了,事实上是一个文件路径。
1055
+ // 符合css后缀名的文件经过mpx处理后会带上相应的后缀防止使用 webpack 的默认解析规则,此时 require/import 相应路径时,导出的不是一段 css 代码了,事实上是一个文件路径。
1056
1056
  const printedParam = printParams(media, dedupe, supports, layer)
1057
1057
  const otherParams = printedParam.length > 0 ? printedParam : ''
1058
1058
  beforeCode += `___CSS_LOADER_EXPORT___.push([module.id, '@import "' + ${item.importName} + '";', ${JSON.stringify(otherParams)} ]);\n`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.15-4",
3
+ "version": "2.10.15-prelease.1",
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",
@@ -83,7 +84,7 @@
83
84
  },
84
85
  "devDependencies": {
85
86
  "@d11/react-native-fast-image": "^8.6.12",
86
- "@mpxjs/api-proxy": "^2.10.13",
87
+ "@mpxjs/api-proxy": "^2.10.15",
87
88
  "@types/babel-traverse": "^6.25.4",
88
89
  "@types/babel-types": "^7.0.4",
89
90
  "@types/react": "^18.2.79",
@@ -1,50 +0,0 @@
1
- const ModuleDependency = require('webpack/lib/dependencies/ModuleDependency')
2
- const { RetryRuntimeGlobal } = require('../retry-runtime-module')
3
- const parseRequest = require('../utils/parse-request')
4
-
5
- class ImportDependencyTemplate extends (
6
- ModuleDependency.Template
7
- ) {
8
- /**
9
- * @param {Dependency} dependency the dependency for which the template should be applied
10
- * @param {ReplaceSource} source the current replace source which can be modified
11
- * @param {DependencyTemplateContext} templateContext the context object
12
- * @returns {void}
13
- */
14
- apply (
15
- dependency,
16
- source,
17
- { runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
18
- ) {
19
- const dep = /** @type {ImportDependency} */ (dependency)
20
- const block = /** @type {AsyncDependenciesBlock} */ (
21
- moduleGraph.getParentBlock(dep)
22
- )
23
- let content = runtimeTemplate.moduleNamespacePromise({
24
- chunkGraph,
25
- block: block,
26
- module: /** @type {Module} */ (moduleGraph.getModule(dep)),
27
- request: dep.request,
28
- strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
29
- message: 'import()',
30
- runtimeRequirements
31
- })
32
- // replace fakeType by 9 to fix require.async to commonjs2 module like 'module.exports = function(){...}'
33
- content = content.replace(/(__webpack_require__\.t\.bind\(.+,\s*)(\d+)(\s*\))/, (_, p1, p2, p3) => {
34
- return p1 + '9' + p3
35
- })
36
-
37
- const { queryObj } = parseRequest(dep.request)
38
- const retryRequireAsync = queryObj.retryRequireAsync && JSON.parse(queryObj.retryRequireAsync)
39
-
40
- // require.async 的场景且配置了重试次数才注入 RetryRuntimeModule
41
- if (queryObj.isRequireAsync && retryRequireAsync && retryRequireAsync.times > 0) {
42
- runtimeRequirements.add(RetryRuntimeGlobal)
43
- content = `${RetryRuntimeGlobal}(function() { return ${content} }, ${retryRequireAsync.times}, ${retryRequireAsync.interval})`
44
- }
45
-
46
- source.replace(dep.range[0], dep.range[1] - 1, content)
47
- }
48
- }
49
-
50
- module.exports = ImportDependencyTemplate