@mpxjs/webpack-plugin 2.8.7 → 2.8.10
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/index.js
CHANGED
|
@@ -59,6 +59,7 @@ const stringifyLoadersAndResource = require('./utils/stringify-loaders-resource'
|
|
|
59
59
|
const emitFile = require('./utils/emit-file')
|
|
60
60
|
const { MPX_PROCESSED_FLAG, MPX_DISABLE_EXTRACTOR_CACHE } = require('./utils/const')
|
|
61
61
|
const isEmptyObject = require('./utils/is-empty-object')
|
|
62
|
+
require('./utils/check-core-version-match')
|
|
62
63
|
|
|
63
64
|
const isProductionLikeMode = options => {
|
|
64
65
|
return options.mode === 'production' || !options.mode
|
|
@@ -167,6 +168,7 @@ class MpxWebpackPlugin {
|
|
|
167
168
|
options.webConfig = options.webConfig || {}
|
|
168
169
|
options.partialCompile = options.mode !== 'web' && options.partialCompile
|
|
169
170
|
options.retryRequireAsync = options.retryRequireAsync || false
|
|
171
|
+
options.enableAliRequireAsync = options.enableAliRequireAsync || false
|
|
170
172
|
this.options = options
|
|
171
173
|
// Hack for buildDependencies
|
|
172
174
|
const rawResolveBuildDependencies = FileSystemInfo.prototype.resolveBuildDependencies
|
|
@@ -575,6 +577,7 @@ class MpxWebpackPlugin {
|
|
|
575
577
|
useRelativePath: this.options.useRelativePath,
|
|
576
578
|
removedChunks: [],
|
|
577
579
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
580
|
+
enableAliRequireAsync: this.options.enableAliRequireAsync,
|
|
578
581
|
pathHash: (resourcePath) => {
|
|
579
582
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
580
583
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
@@ -985,7 +988,7 @@ class MpxWebpackPlugin {
|
|
|
985
988
|
// 删除root query
|
|
986
989
|
request = addQuery(request, {}, false, ['root'])
|
|
987
990
|
// 目前仅wx支持require.async,其余平台使用CommonJsAsyncDependency进行模拟抹平
|
|
988
|
-
if (mpx.mode === 'wx') {
|
|
991
|
+
if (mpx.mode === 'wx' || (mpx.mode === 'ali' && mpx.enableAliRequireAsync)) {
|
|
989
992
|
const dep = new DynamicEntryDependency(request, 'export', '', queryObj.root, '', context, range, {
|
|
990
993
|
isRequireAsync: true,
|
|
991
994
|
retryRequireAsync: !!this.options.retryRequireAsync
|
|
@@ -16,6 +16,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
16
16
|
const pathHash = mpx.pathHash
|
|
17
17
|
const getOutputPath = mpx.getOutputPath
|
|
18
18
|
const mode = mpx.mode
|
|
19
|
+
const enableAliRequireAsync = mpx.enableAliRequireAsync
|
|
19
20
|
|
|
20
21
|
const isUrlRequest = r => isUrlRequestRaw(r, root, externals)
|
|
21
22
|
const urlToRequest = r => loaderUtils.urlToRequest(r)
|
|
@@ -53,7 +54,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
53
54
|
// 删除root query
|
|
54
55
|
resource = addQuery(resource, {}, false, ['root'])
|
|
55
56
|
// 目前只有微信支持分包异步化
|
|
56
|
-
if (mode === 'wx') tarRoot = queryObj.root
|
|
57
|
+
if (mode === 'wx' || (mode === 'ali' && enableAliRequireAsync)) tarRoot = queryObj.root
|
|
57
58
|
}
|
|
58
59
|
const parsed = path.parse(resourcePath)
|
|
59
60
|
const ext = parsed.ext
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @mpxjs/webpack-plugin 2.7.x -> @mpxjs/core 2.7.x
|
|
2
|
+
// @mpxjs/webpack-plugin 2.8.x -> @mpxjs/core 2.8.x
|
|
3
|
+
const coreVersion = require('@mpxjs/core/package.json').version
|
|
4
|
+
const packageName = require('../../package.json').name
|
|
5
|
+
const packageVersion = require('../../package.json').version
|
|
6
|
+
|
|
7
|
+
if (packageVersion.slice(0, 3) !== coreVersion.slice(0, 3)) {
|
|
8
|
+
const corePath = require.resolve('@mpxjs/core')
|
|
9
|
+
const packagePath = require.resolve('../../package.json')
|
|
10
|
+
throw new Error(
|
|
11
|
+
`@mpxjs/core packages version mismatch:
|
|
12
|
+
-@mpxjs/core@${coreVersion}(${corePath})
|
|
13
|
+
-${packageName}@${packageVersion}(${packagePath})
|
|
14
|
+
This may cause things to work incorrectly, Make sure to use the same minor version for both.
|
|
15
|
+
For example: @mpxjs/core@2.7.x with @mpxjs/webpack-plugin@2.7.x
|
|
16
|
+
`
|
|
17
|
+
)
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.10",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "f17e671af3371f763cdcdcc6afbb06100f1f054d"
|
|
86
86
|
}
|