@mpxjs/webpack-plugin 2.10.7-beta.1 → 2.10.7-beta.11

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 (47) hide show
  1. package/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
  2. package/lib/file-loader.js +1 -1
  3. package/lib/index.js +78 -86
  4. package/lib/parser.js +1 -1
  5. package/lib/platform/json/wx/index.js +25 -43
  6. package/lib/platform/style/wx/index.js +7 -0
  7. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  8. package/lib/platform/template/wx/component-config/movable-view.js +1 -10
  9. package/lib/platform/template/wx/index.js +1 -2
  10. package/lib/react/index.js +1 -3
  11. package/lib/react/processJSON.js +11 -66
  12. package/lib/react/processScript.js +3 -4
  13. package/lib/react/script-helper.js +18 -92
  14. package/lib/runtime/components/react/AsyncContainer.tsx +7 -35
  15. package/lib/runtime/components/react/context.ts +12 -2
  16. package/lib/runtime/components/react/dist/AsyncContainer.jsx +4 -23
  17. package/lib/runtime/components/react/dist/context.js +1 -1
  18. package/lib/runtime/components/react/dist/getInnerListeners.js +1 -1
  19. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +63 -9
  20. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +308 -63
  21. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +15 -10
  22. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +3 -1
  23. package/lib/runtime/components/react/dist/mpx-web-view.jsx +28 -14
  24. package/lib/runtime/components/react/dist/useAnimationHooks.js +87 -2
  25. package/lib/runtime/components/react/dist/utils.jsx +2 -13
  26. package/lib/runtime/components/react/getInnerListeners.ts +1 -1
  27. package/lib/runtime/components/react/mpx-movable-area.tsx +98 -11
  28. package/lib/runtime/components/react/mpx-movable-view.tsx +358 -64
  29. package/lib/runtime/components/react/mpx-scroll-view.tsx +16 -9
  30. package/lib/runtime/components/react/mpx-sticky-header.tsx +3 -1
  31. package/lib/runtime/components/react/mpx-web-view.tsx +33 -13
  32. package/lib/runtime/components/react/types/global.d.ts +0 -15
  33. package/lib/runtime/components/react/useAnimationHooks.ts +85 -2
  34. package/lib/runtime/components/react/utils.tsx +2 -13
  35. package/lib/runtime/components/web/mpx-scroll-view.vue +4 -7
  36. package/lib/runtime/components/web/mpx-sticky-header.vue +39 -31
  37. package/lib/runtime/optionProcessor.js +6 -2
  38. package/lib/script-setup-compiler/index.js +27 -5
  39. package/lib/template-compiler/bind-this.js +2 -1
  40. package/lib/template-compiler/compiler.js +4 -3
  41. package/lib/utils/dom-tag-config.js +3 -17
  42. package/lib/web/processTemplate.js +1 -1
  43. package/lib/web/script-helper.js +1 -1
  44. package/package.json +2 -2
  45. package/lib/react/LoadAsyncChunkModule.js +0 -68
  46. package/lib/runtime/components/react/AsyncSuspense.tsx +0 -81
  47. package/lib/runtime/components/react/dist/AsyncSuspense.jsx +0 -68
@@ -29,7 +29,7 @@ class RecordPageConfigMapDependency extends NullDependency {
29
29
 
30
30
  deserialize (context) {
31
31
  const { read } = context
32
- this.pagePath = read()
32
+ this.resourcePath = read()
33
33
  this.jsonObj = read()
34
34
  super.deserialize(context)
35
35
  }
@@ -36,7 +36,7 @@ module.exports = function loader (content, prevOptions) {
36
36
  let publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`
37
37
 
38
38
  // todo 未来添加分包处理后相对地址不一定是./开头的,需要考虑通过dependency的方式在sourceModule时通过最终的chunkName得到准确的相对路径
39
- if (isRN) publicPath = `__non_webpack_require__(${JSON.stringify(`_mpx_rn_img_relative_path_/${url}`)})`
39
+ if (isRN) publicPath = `__non_webpack_require__(${JSON.stringify(`./${url}`)})`
40
40
 
41
41
  if (options.publicPath) {
42
42
  if (typeof options.publicPath === 'function') {
package/lib/index.js CHANGED
@@ -72,8 +72,6 @@ const isEmptyObject = require('./utils/is-empty-object')
72
72
  const DynamicPlugin = require('./resolver/DynamicPlugin')
73
73
  const { isReact, isWeb } = require('./utils/env')
74
74
  const VirtualModulesPlugin = require('webpack-virtual-modules')
75
- const RuntimeGlobals = require('webpack/lib/RuntimeGlobals')
76
- const LoadAsyncChunkModule = require('./react/LoadAsyncChunkModule')
77
75
  require('./utils/check-core-version-match')
78
76
 
79
77
  const isProductionLikeMode = options => {
@@ -410,7 +408,7 @@ class MpxWebpackPlugin {
410
408
  let splitChunksOptions = null
411
409
  let splitChunksPlugin = null
412
410
  // 输出web ssr需要将optimization.splitChunks设置为false以关闭splitChunks
413
- if (optimization.splitChunks !== false) {
411
+ if (optimization.splitChunks !== false && !isReact(this.options.mode)) {
414
412
  splitChunksOptions = Object.assign({
415
413
  chunks: 'all',
416
414
  usedExports: optimization.usedExports === true,
@@ -608,22 +606,6 @@ class MpxWebpackPlugin {
608
606
  return mpx
609
607
  }
610
608
  })
611
-
612
- if (isReact(this.options.mode)) {
613
- compilation.hooks.runtimeRequirementInTree
614
- .for(RuntimeGlobals.loadScript)
615
- .tap({
616
- stage: -1000,
617
- name: 'LoadAsyncChunk'
618
- }, (chunk, set) => {
619
- compilation.addRuntimeModule(
620
- chunk,
621
- new LoadAsyncChunkModule(this.options.rnConfig && this.options.rnConfig.asyncChunk && this.options.rnConfig.asyncChunk.timeout)
622
- )
623
- return true
624
- })
625
- }
626
-
627
609
  compilation.dependencyFactories.set(ResolveDependency, new NullFactory())
628
610
  compilation.dependencyTemplates.set(ResolveDependency, new ResolveDependency.Template())
629
611
 
@@ -758,7 +740,7 @@ class MpxWebpackPlugin {
758
740
  removedChunks: [],
759
741
  forceProxyEventRules: this.options.forceProxyEventRules,
760
742
  // 若配置disableRequireAsync=true, 则全平台构建不支持异步分包
761
- supportRequireAsync: !this.options.disableRequireAsync && (this.options.mode === 'wx' || this.options.mode === 'ali' || this.options.mode === 'tt' || isWeb(this.options.mode) || isReact(this.options.mode)),
743
+ supportRequireAsync: !this.options.disableRequireAsync && (this.options.mode === 'wx' || this.options.mode === 'ali' || this.options.mode === 'tt' || isWeb(this.options.mode)),
762
744
  partialCompileRules: this.options.partialCompileRules,
763
745
  collectDynamicEntryInfo: ({ resource, packageName, filename, entryType, hasAsync }) => {
764
746
  const curInfo = mpx.dynamicEntryInfo[packageName] = mpx.dynamicEntryInfo[packageName] || {
@@ -1217,12 +1199,12 @@ class MpxWebpackPlugin {
1217
1199
  // 自动使用分包配置修改splitChunksPlugin配置
1218
1200
  if (splitChunksPlugin) {
1219
1201
  let needInit = false
1220
- if (isWeb(mpx.mode) || isReact(mpx.mode)) {
1202
+ if (isWeb(mpx.mode)) {
1221
1203
  // web独立处理splitChunk
1222
- if (isWeb(mpx.mode) && !hasOwn(splitChunksOptions.cacheGroups, 'main')) {
1204
+ if (!hasOwn(splitChunksOptions.cacheGroups, 'main')) {
1223
1205
  splitChunksOptions.cacheGroups.main = {
1224
1206
  chunks: 'initial',
1225
- name: 'bundle/index', // web 输出 chunk 路径和 rn 输出分包格式拉齐
1207
+ name: 'bundle',
1226
1208
  test: /[\\/]node_modules[\\/]/
1227
1209
  }
1228
1210
  needInit = true
@@ -1230,7 +1212,7 @@ class MpxWebpackPlugin {
1230
1212
  if (!hasOwn(splitChunksOptions.cacheGroups, 'async')) {
1231
1213
  splitChunksOptions.cacheGroups.async = {
1232
1214
  chunks: 'async',
1233
- name: 'async/index',
1215
+ name: 'async',
1234
1216
  minChunks: 2
1235
1217
  }
1236
1218
  needInit = true
@@ -1333,15 +1315,6 @@ class MpxWebpackPlugin {
1333
1315
  compilation.hooks.processAssets.tap({
1334
1316
  name: 'MpxWebpackPlugin'
1335
1317
  }, (assets) => {
1336
- if (isReact(mpx.mode)) {
1337
- Object.keys(assets).forEach((chunkName) => {
1338
- if (/\.js$/.test(chunkName)) {
1339
- let val = assets[chunkName].source()
1340
- val = val.replace(/_mpx_rn_img_relative_path_/g, chunkName === 'app.js' ? '.' : '..')
1341
- compilation.assets[chunkName] = new RawSource(val)
1342
- }
1343
- })
1344
- }
1345
1318
  try {
1346
1319
  const dynamicAssets = {}
1347
1320
  for (const packageName in mpx.runtimeInfo) {
@@ -1416,10 +1389,10 @@ class MpxWebpackPlugin {
1416
1389
  if (queryObj.root) request = addQuery(request, {}, false, ['root'])
1417
1390
  // wx、ali和web平台支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
1418
1391
  if (mpx.supportRequireAsync) {
1419
- if (isWeb(mpx.mode) || isReact(mpx.mode)) {
1392
+ if (isWeb(mpx.mode)) {
1420
1393
  const depBlock = new AsyncDependenciesBlock(
1421
1394
  {
1422
- name: tarRoot + '/index'
1395
+ name: tarRoot
1423
1396
  },
1424
1397
  expr.loc,
1425
1398
  request
@@ -1843,72 +1816,91 @@ try {
1843
1816
  const { queryObj } = parseRequest(createData.request)
1844
1817
  const loaders = createData.loaders
1845
1818
  const type = queryObj.type
1846
- if ((queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) || queryObj.vue) {
1819
+ const mpxProcessFlag = queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG
1820
+ const vueProcessFlag = queryObj.vue && queryObj.mpx !== MPX_PROCESSED_FLAG
1821
+ if (mpxProcessFlag || vueProcessFlag) {
1822
+ const extract = queryObj.extract
1847
1823
  if (type === 'styles' || type === 'style') {
1848
- let insertBeforeIndex = -1
1849
- // 单次遍历收集所有索引
1824
+ const loaderTypes = {
1825
+ 'node_modules/stylus-loader': -1,
1826
+ 'node_modules/sass-loader': -1,
1827
+ 'node_modules/less-loader': -1,
1828
+ 'node_modules/css-loader': -1
1829
+ }
1850
1830
  loaders.forEach((loader, index) => {
1851
1831
  const currentLoader = toPosix(loader.loader)
1852
- if (currentLoader.includes('node_modules/stylus-loader') || currentLoader.includes('node_modules/sass-loader') || currentLoader.includes('node_modules/less-loader')) {
1853
- insertBeforeIndex = index
1832
+ for (const key in loaderTypes) {
1833
+ if (currentLoader.includes(key)) {
1834
+ loaderTypes[key] = index
1835
+ break
1836
+ }
1854
1837
  }
1855
1838
  })
1839
+ const insertStripLoaders = (index) => {
1840
+ if (index !== -1) {
1841
+ loaders.splice(index, 0, { loader: styleStripConditionalPath, options: {id: 0} })
1842
+ loaders.splice(index + 2, 0, { loader: styleStripConditionalPath, options: {id: 1} })
1843
+ return true
1844
+ }
1845
+ return false
1846
+ }
1856
1847
 
1857
- if (insertBeforeIndex !== -1) {
1858
- loaders.splice(insertBeforeIndex, 0, { loader: styleStripConditionalPath })
1848
+ const priorities = ['node_modules/stylus-loader', 'node_modules/less-loader', 'node_modules/sass-loader', 'node_modules/css-loader']
1849
+ for (const loaderKey of priorities) {
1850
+ if (insertStripLoaders(loaderTypes[loaderKey])) {
1851
+ break
1852
+ }
1859
1853
  }
1860
- loaders.push({ loader: styleStripConditionalPath })
1861
1854
  }
1862
- }
1863
1855
 
1864
- if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
1865
- const extract = queryObj.extract
1866
- switch (type) {
1867
- case 'styles':
1868
- case 'template': {
1869
- let insertBeforeIndex = -1
1870
- const info = typeLoaderProcessInfo[type]
1871
- loaders.forEach((loader, index) => {
1872
- const currentLoader = toPosix(loader.loader)
1873
- if (currentLoader.includes(info[0])) {
1874
- loader.loader = info[1]
1875
- insertBeforeIndex = index
1876
- } else if (currentLoader.includes(info[1])) {
1877
- insertBeforeIndex = index
1878
- }
1879
- })
1880
- if (insertBeforeIndex > -1) {
1881
- loaders.splice(insertBeforeIndex + 1, 0, {
1882
- loader: info[2]
1856
+ if (mpxProcessFlag) {
1857
+ switch (type) {
1858
+ case 'styles':
1859
+ case 'template': {
1860
+ let insertBeforeIndex = -1
1861
+ const info = typeLoaderProcessInfo[type]
1862
+ loaders.forEach((loader, index) => {
1863
+ const currentLoader = toPosix(loader.loader)
1864
+ if (currentLoader.includes(info[0])) {
1865
+ loader.loader = info[1]
1866
+ insertBeforeIndex = index
1867
+ } else if (currentLoader.includes(info[1])) {
1868
+ insertBeforeIndex = index
1869
+ }
1883
1870
  })
1871
+ if (insertBeforeIndex > -1) {
1872
+ loaders.splice(insertBeforeIndex + 1, 0, {
1873
+ loader: info[2]
1874
+ })
1875
+ }
1876
+ break
1884
1877
  }
1885
- break
1886
- }
1887
- case 'json':
1888
- if (queryObj.isTheme) {
1889
- loaders.unshift({
1890
- loader: jsonThemeCompilerPath
1891
- })
1892
- } else if (queryObj.isPlugin) {
1893
- loaders.unshift({
1894
- loader: jsonPluginCompilerPath
1895
- })
1896
- } else {
1878
+ case 'json':
1879
+ if (queryObj.isTheme) {
1880
+ loaders.unshift({
1881
+ loader: jsonThemeCompilerPath
1882
+ })
1883
+ } else if (queryObj.isPlugin) {
1884
+ loaders.unshift({
1885
+ loader: jsonPluginCompilerPath
1886
+ })
1887
+ } else {
1888
+ loaders.unshift({
1889
+ loader: jsonCompilerPath
1890
+ })
1891
+ }
1892
+ break
1893
+ case 'wxs':
1897
1894
  loaders.unshift({
1898
- loader: jsonCompilerPath
1895
+ loader: wxsLoaderPath
1899
1896
  })
1900
- }
1901
- break
1902
- case 'wxs':
1897
+ break
1898
+ }
1899
+ if (extract) {
1903
1900
  loaders.unshift({
1904
- loader: wxsLoaderPath
1901
+ loader: extractorPath
1905
1902
  })
1906
- break
1907
- }
1908
- if (extract) {
1909
- loaders.unshift({
1910
- loader: extractorPath
1911
- })
1903
+ }
1912
1904
  }
1913
1905
  createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
1914
1906
  }
package/lib/parser.js CHANGED
@@ -14,7 +14,7 @@ module.exports = (content, { filePath, needMap, mode, env }) => {
14
14
  output = compiler.parseComponent(content, {
15
15
  mode,
16
16
  filePath,
17
- // pad: 'line', // stylus编译遇到大量空行时会出现栈溢出,故注释掉
17
+ pad: 'line',
18
18
  env
19
19
  })
20
20
  if (needMap) {
@@ -3,7 +3,7 @@ const normalizeTest = require('../normalize-test')
3
3
  const changeKey = require('../change-key')
4
4
  const normalize = require('../../../utils/normalize')
5
5
  const { capitalToHyphen } = require('../../../utils/string')
6
- const { isOriginTag, isBuildInWebTag, isBuildInReactTag } = require('../../../utils/dom-tag-config')
6
+ const { isOriginTag, isBuildInTag } = require('../../../utils/dom-tag-config')
7
7
 
8
8
  const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
9
9
  const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
@@ -128,41 +128,19 @@ module.exports = function getSpec ({ warn, error }) {
128
128
  /**
129
129
  * 将小程序代码中使用的与原生 HTML tag 或 内建组件 同名的组件进行转化,以解决与原生tag命名冲突问题。
130
130
  */
131
- function fixComponentName (input, { mode }) {
132
- const isNeedFixTag = (tag) => {
133
- switch (mode) {
134
- case 'web': return isOriginTag(tag) || isBuildInWebTag(tag)
135
- case 'ios':
136
- case 'android':
137
- case 'harmony': return isOriginTag(tag) || isBuildInReactTag(tag)
138
- }
139
- }
140
-
141
- const usingComponents = input.usingComponents
142
- const componentPlaceholder = input.componentPlaceholder
143
- if (usingComponents) {
144
- const transfromKeys = []
145
- Object.keys(usingComponents).forEach(tag => {
146
- if (isNeedFixTag(tag)) {
147
- usingComponents[`mpx-com-${tag}`] = usingComponents[tag]
148
- delete usingComponents[tag]
149
- transfromKeys.push(tag)
150
- }
151
- })
152
-
153
- if (transfromKeys.length && componentPlaceholder) {
154
- Object.keys(componentPlaceholder).forEach(key => {
155
- if (transfromKeys.includes(componentPlaceholder[key])) {
156
- componentPlaceholder[key] = `mpx-com-${componentPlaceholder[key]}`
157
- }
158
- if (transfromKeys.includes(key)) {
159
- componentPlaceholder[`mpx-com-${key}`] = componentPlaceholder[key]
160
- delete componentPlaceholder[key]
131
+ function fixComponentName (type) {
132
+ return function (input) {
133
+ const usingComponents = input[type]
134
+ if (usingComponents) {
135
+ Object.keys(usingComponents).forEach(tag => {
136
+ if (isOriginTag(tag) || isBuildInTag(tag)) {
137
+ usingComponents[`mpx-com-${tag}`] = usingComponents[tag]
138
+ delete usingComponents[tag]
161
139
  }
162
140
  })
163
141
  }
142
+ return input
164
143
  }
165
- return input
166
144
  }
167
145
 
168
146
  const componentRules = [
@@ -176,6 +154,13 @@ module.exports = function getSpec ({ warn, error }) {
176
154
  swan: deletePath(),
177
155
  jd: deletePath()
178
156
  },
157
+ {
158
+ test: 'usingComponents',
159
+ web: fixComponentName('usingComponents'),
160
+ ios: fixComponentName('usingComponents'),
161
+ android: fixComponentName('usingComponents'),
162
+ harmony: fixComponentName('usingComponents')
163
+ },
179
164
  {
180
165
  test: 'usingComponents',
181
166
  ali: componentNameCapitalToHyphen('usingComponents'),
@@ -185,11 +170,7 @@ module.exports = function getSpec ({ warn, error }) {
185
170
  swan: addGlobalComponents,
186
171
  qq: addGlobalComponents,
187
172
  tt: addGlobalComponents,
188
- jd: addGlobalComponents,
189
- web: fixComponentName,
190
- ios: fixComponentName,
191
- android: fixComponentName,
192
- harmony: fixComponentName
173
+ jd: addGlobalComponents
193
174
  }
194
175
  ]
195
176
 
@@ -390,6 +371,13 @@ module.exports = function getSpec ({ warn, error }) {
390
371
  tt: deletePath(),
391
372
  jd: deletePath(true)
392
373
  },
374
+ {
375
+ test: 'usingComponents',
376
+ web: fixComponentName('usingComponents'),
377
+ ios: fixComponentName('usingComponents'),
378
+ android: fixComponentName('usingComponents'),
379
+ harmony: fixComponentName('usingComponents')
380
+ },
393
381
  {
394
382
  test: 'usingComponents',
395
383
  ali: componentNameCapitalToHyphen('usingComponents'),
@@ -454,12 +442,6 @@ module.exports = function getSpec ({ warn, error }) {
454
442
  swan: getWindowRule(),
455
443
  tt: getWindowRule(),
456
444
  jd: getWindowRule()
457
- },
458
- {
459
- web: fixComponentName,
460
- ios: fixComponentName,
461
- android: fixComponentName,
462
- harmony: fixComponentName
463
445
  }
464
446
  ]
465
447
  }
@@ -285,6 +285,13 @@ module.exports = function getSpec ({ warn, error }) {
285
285
 
286
286
  // line-height
287
287
  const formatLineHeight = ({ prop, value, selector }) => {
288
+ // line-height 0 直接返回
289
+ if (+value === 0) {
290
+ return {
291
+ prop,
292
+ value
293
+ }
294
+ }
288
295
  return verifyValues({ prop, value, selector }) && ({
289
296
  prop,
290
297
  value: /^\s*(-?(\d+(\.\d+)?|\.\d+))\s*$/.test(value) ? `${Math.round(value * 100)}%` : value
@@ -1,4 +1,4 @@
1
- const { isOriginTag, isBuildInWebTag } = require('../../../../utils/dom-tag-config')
1
+ const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')
2
2
 
3
3
  module.exports = function () {
4
4
  const handleComponentTag = (el, data) => {
@@ -16,7 +16,7 @@ module.exports = function () {
16
16
  waterfall: true,
17
17
  skipNormalize: true,
18
18
  supportedModes: ['web', 'ios', 'android', 'harmony'],
19
- test: (input) => isOriginTag(input) || isBuildInWebTag(input),
19
+ test: (input) => isOriginTag(input) || isBuildInTag(input),
20
20
  web: handleComponentTag,
21
21
  ios: handleComponentTag,
22
22
  android: handleComponentTag,
@@ -2,9 +2,6 @@ const TAG_NAME = 'movable-view'
2
2
 
3
3
  module.exports = function ({ print }) {
4
4
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
5
- const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
6
- const harmonyEventLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false, type: 'event' })
7
- const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
8
5
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
9
6
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
10
7
  const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
@@ -36,7 +33,7 @@ module.exports = function ({ print }) {
36
33
  harmony: harmonyPropLog
37
34
  },
38
35
  {
39
- test: /^(damping|friction|scale|scale-min|scale-max|scale-value)$/,
36
+ test: /^(damping|friction)$/,
40
37
  ios: iosPropLog,
41
38
  android: androidPropLog,
42
39
  harmony: harmonyPropLog
@@ -46,12 +43,6 @@ module.exports = function ({ print }) {
46
43
  {
47
44
  test: /^(htouchmove|vtouchmove)$/,
48
45
  ali: aliEventLog
49
- },
50
- {
51
- test: /^(bindscale)$/,
52
- ios: iosEventLog,
53
- android: androidEventLog,
54
- harmony: harmonyEventLog
55
46
  }
56
47
  ]
57
48
  }
@@ -34,8 +34,7 @@ module.exports = function getSpec ({ warn, error }) {
34
34
  touchstart: 'touchstart',
35
35
  touchmove: 'touchmove',
36
36
  touchend: 'touchend',
37
- touchcancel: 'touchcancel',
38
- transitionend: 'transitionend'
37
+ touchcancel: 'touchcancel'
39
38
  }
40
39
  if (eventMap[eventName]) {
41
40
  return eventMap[eventName]
@@ -35,7 +35,6 @@ module.exports = function ({
35
35
  })
36
36
  }
37
37
  const mpx = loaderContext.getMpx()
38
- const rnConfig = mpx.rnConfig
39
38
  // 通过RecordLoaderContentDependency和loaderContentCache确保子request不再重复生成loaderContent
40
39
  const cacheContent = mpx.loaderContentCache.get(loaderContext.resourcePath)
41
40
  if (cacheContent) return callback(null, cacheContent)
@@ -92,8 +91,7 @@ module.exports = function ({
92
91
  genericsInfo: templateRes.genericsInfo,
93
92
  wxsModuleMap: templateRes.wxsModuleMap,
94
93
  localComponentsMap: jsonRes.localComponentsMap,
95
- localPagesMap: jsonRes.localPagesMap,
96
- rnConfig
94
+ localPagesMap: jsonRes.localPagesMap
97
95
  }, callback)
98
96
  }
99
97
  ], (err, scriptRes) => {
@@ -11,11 +11,8 @@ const resolve = require('../utils/resolve')
11
11
  const createJSONHelper = require('../json-compiler/helper')
12
12
  const getRulesRunner = require('../platform/index')
13
13
  const { RESOLVE_IGNORED_ERR } = require('../utils/const')
14
- const normalize = require('../utils/normalize')
15
14
  const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
16
15
  const RecordPageConfigsMapDependency = require('../dependencies/RecordPageConfigsMapDependency')
17
- const mpxViewPath = normalize.lib('runtime/components/react/dist/mpx-view.jsx')
18
- const mpxTextPath = normalize.lib('runtime/components/react/dist/mpx-text.jsx')
19
16
 
20
17
  module.exports = function (jsonContent, {
21
18
  loaderContext,
@@ -136,29 +133,6 @@ module.exports = function (jsonContent, {
136
133
  isShow: true
137
134
  }
138
135
 
139
- const fillInComponentPlaceholder = (name, placeholder, placeholderEntry) => {
140
- const componentPlaceholder = jsonObj.componentPlaceholder || {}
141
- if (componentPlaceholder[name]) return
142
- componentPlaceholder[name] = placeholder
143
- jsonObj.componentPlaceholder = componentPlaceholder
144
- if (placeholderEntry && !jsonObj.usingComponents[placeholder]) jsonObj.usingComponents[placeholder] = placeholderEntry
145
- }
146
- const normalizePlaceholder = (placeholder) => {
147
- if (typeof placeholder === 'string') {
148
- const placeholderMap = mode === 'ali'
149
- ? {
150
- view: { name: 'mpx-view', resource: mpxViewPath },
151
- text: { name: 'mpx-text', resource: mpxTextPath }
152
- }
153
- : {}
154
- placeholder = placeholderMap[placeholder] || { name: placeholder }
155
- }
156
- if (!placeholder.name) {
157
- emitError('The asyncSubpackageRules configuration format of @mpxjs/webpack-plugin a is incorrect')
158
- }
159
- return placeholder
160
- }
161
-
162
136
  const processTabBar = (tabBar, callback) => {
163
137
  if (tabBar) {
164
138
  tabBar = Object.assign({}, defaultTabbar, tabBar)
@@ -327,48 +301,19 @@ module.exports = function (jsonContent, {
327
301
  const processComponents = (components, context, callback) => {
328
302
  if (components) {
329
303
  async.eachOf(components, (component, name, callback) => {
330
- processComponent(component, context, {}, (err, entry = {}, { tarRoot, placeholder } = {}) => {
304
+ processComponent(component, context, {}, (err, { resource, outputPath } = {}, { tarRoot } = {}) => {
331
305
  if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
332
- const fillComponentsMap = (name, entry, tarRoot) => {
333
- const { resource, outputPath } = entry
334
- const { resourcePath, queryObj } = parseRequest(resource)
335
- componentsMap[resourcePath] = outputPath
336
- loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
337
- localComponentsMap[name] = {
338
- resource: addQuery(resource, {
339
- isComponent: true,
340
- outputPath
341
- }),
342
- async: queryObj.async || tarRoot
343
- }
344
- }
345
- fillComponentsMap(name, entry, tarRoot)
346
- const { relativePath } = entry
347
-
348
- if (tarRoot) {
349
- if (placeholder) {
350
- placeholder = normalizePlaceholder(placeholder)
351
- if (placeholder.resource) {
352
- processComponent(placeholder.resource, projectRoot, { relativePath }, (err, entry) => {
353
- if (err) return callback(err)
354
- fillInComponentPlaceholder(name, placeholder.name, entry)
355
- fillComponentsMap(placeholder.name, entry, '')
356
- callback()
357
- })
358
- } else {
359
- fillInComponentPlaceholder(name, placeholder.name)
360
- callback()
361
- }
362
- } else {
363
- if (!jsonObj.componentPlaceholder || !jsonObj.componentPlaceholder[name]) {
364
- const errMsg = `componentPlaceholder of "${name}" doesn't exist! \n\r`
365
- emitError(errMsg)
366
- }
367
- callback()
368
- }
369
- } else {
370
- callback()
306
+ const { resourcePath, queryObj } = parseRequest(resource)
307
+ componentsMap[resourcePath] = outputPath
308
+ loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
309
+ localComponentsMap[name] = {
310
+ resource: addQuery(resource, {
311
+ isComponent: true,
312
+ outputPath
313
+ }),
314
+ async: queryObj.async || tarRoot
371
315
  }
316
+ callback()
372
317
  })
373
318
  }, callback)
374
319
  } else {
@@ -13,7 +13,6 @@ module.exports = function (script, {
13
13
  builtInComponentsMap,
14
14
  localComponentsMap,
15
15
  localPagesMap,
16
- rnConfig,
17
16
  componentGenerics,
18
17
  genericsInfo
19
18
  }, callback) {
@@ -33,7 +32,6 @@ module.exports = function (script, {
33
32
  }
34
33
 
35
34
  let output = '/* script */\n'
36
- output += "import { lazy, createElement, memo, forwardRef } from 'react'\n"
37
35
  if (ctorType === 'app') {
38
36
  output += `
39
37
  import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPath)}
@@ -41,8 +39,7 @@ import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPa
41
39
  const { pagesMap, firstPage } = buildPagesMap({
42
40
  localPagesMap,
43
41
  loaderContext,
44
- jsonConfig,
45
- rnConfig
42
+ jsonConfig
46
43
  })
47
44
  const componentsMap = buildComponentsMap({
48
45
  localComponentsMap,
@@ -53,6 +50,8 @@ import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPa
53
50
  output += getRequireScript({ ctorType, script, loaderContext })
54
51
  output += `export default global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
55
52
  } else {
53
+ // RN环境暂不支持异步加载
54
+ // output += 'import { lazy } from \'react\'\n'
56
55
  output += `import { getComponent } from ${stringifyRequest(loaderContext, optionProcessorPath)}\n`
57
56
  // 获取组件集合
58
57
  const componentsMap = buildComponentsMap({