@mpxjs/webpack-plugin 2.10.14-beta.16 → 2.10.14-beta.17

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 (2) hide show
  1. package/lib/index.js +17 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -48,6 +48,7 @@ const SplitChunksPlugin = require('webpack/lib/optimize/SplitChunksPlugin')
48
48
  const fixRelative = require('./utils/fix-relative')
49
49
  const parseRequest = require('./utils/parse-request')
50
50
  const { transSubpackage } = require('./utils/trans-async-sub-rules')
51
+ const getEntryName = require('./utils/get-entry-name')
51
52
  const { matchCondition } = require('./utils/match-condition')
52
53
  const processDefs = require('./utils/process-defs')
53
54
  const config = require('./config')
@@ -1450,10 +1451,24 @@ class MpxWebpackPlugin {
1450
1451
  // wx、ali和web平台支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
1451
1452
  if (mpx.supportRequireAsync) {
1452
1453
  if (isWeb(mpx.mode) || isReact(mpx.mode)) {
1453
- if (isReact(mpx.mode)) tarRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
1454
+ let depName = tarRoot + '/index'
1455
+ if (isReact(mpx.mode)) {
1456
+ const transRoot = transSubpackage(mpx.transSubpackageRules, tarRoot)
1457
+ if (transRoot !== tarRoot) {
1458
+ if (transRoot === '') {
1459
+ const entryName = getEntryName({
1460
+ _compilation: compilation,
1461
+ resource: parser.state.module.resource
1462
+ })
1463
+ if (entryName) depName = entryName
1464
+ } else {
1465
+ depName = transRoot + '/index'
1466
+ }
1467
+ }
1468
+ }
1454
1469
  const depBlock = new AsyncDependenciesBlock(
1455
1470
  {
1456
- name: tarRoot + '/index'
1471
+ name: depName
1457
1472
  },
1458
1473
  expr.loc,
1459
1474
  request
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.14-beta.16",
3
+ "version": "2.10.14-beta.17",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"