@mpxjs/webpack-plugin 2.7.11 → 2.7.14
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
|
@@ -11,6 +11,7 @@ const CommonJsAsyncDependency = require('./dependencies/CommonJsAsyncDependency'
|
|
|
11
11
|
const NormalModule = require('webpack/lib/NormalModule')
|
|
12
12
|
const EntryPlugin = require('webpack/lib/EntryPlugin')
|
|
13
13
|
const JavascriptModulesPlugin = require('webpack/lib/javascript/JavascriptModulesPlugin')
|
|
14
|
+
const FileSystemInfo = require('webpack/lib/FileSystemInfo')
|
|
14
15
|
const normalize = require('./utils/normalize')
|
|
15
16
|
const toPosix = require('./utils/to-posix')
|
|
16
17
|
const addQuery = require('./utils/add-query')
|
|
@@ -129,7 +130,7 @@ class MpxWebpackPlugin {
|
|
|
129
130
|
})
|
|
130
131
|
// 批量指定源码mode
|
|
131
132
|
options.modeRules = options.modeRules || {}
|
|
132
|
-
options.generateBuildMap = options.generateBuildMap || false
|
|
133
|
+
// options.generateBuildMap = options.generateBuildMap || false
|
|
133
134
|
options.attributes = options.attributes || []
|
|
134
135
|
options.externals = (options.externals || []).map((external) => {
|
|
135
136
|
return externalsMap[external] || external
|
|
@@ -159,6 +160,14 @@ class MpxWebpackPlugin {
|
|
|
159
160
|
}, options.nativeConfig)
|
|
160
161
|
options.webConfig = options.webConfig || {}
|
|
161
162
|
this.options = options
|
|
163
|
+
// Hack for buildDependencies
|
|
164
|
+
const rawResolveBuildDependencies = FileSystemInfo.prototype.resolveBuildDependencies
|
|
165
|
+
FileSystemInfo.prototype.resolveBuildDependencies = function (context, deps, rawCallback) {
|
|
166
|
+
return rawResolveBuildDependencies.call(this, context, deps, (err, result) => {
|
|
167
|
+
if (result && typeof options.hackResolveBuildDependencies === 'function') options.hackResolveBuildDependencies(result)
|
|
168
|
+
return rawCallback(err, result)
|
|
169
|
+
})
|
|
170
|
+
}
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
static loader (options = {}) {
|
|
@@ -1121,6 +1130,23 @@ class MpxWebpackPlugin {
|
|
|
1121
1130
|
}, () => {
|
|
1122
1131
|
if (mpx.mode === 'web') return
|
|
1123
1132
|
|
|
1133
|
+
// if (this.options.generateBuildMap) {
|
|
1134
|
+
// const pagesMap = compilation.__mpx__.pagesMap
|
|
1135
|
+
// const componentsPackageMap = compilation.__mpx__.componentsMap
|
|
1136
|
+
// const componentsMap = Object.keys(componentsPackageMap).map(item => componentsPackageMap[item]).reduce((pre, cur) => {
|
|
1137
|
+
// return { ...pre, ...cur }
|
|
1138
|
+
// }, {})
|
|
1139
|
+
// const outputMap = JSON.stringify({ ...pagesMap, ...componentsMap })
|
|
1140
|
+
// compilation.assets['../outputMap.json'] = {
|
|
1141
|
+
// source: () => {
|
|
1142
|
+
// return outputMap
|
|
1143
|
+
// },
|
|
1144
|
+
// size: () => {
|
|
1145
|
+
// return Buffer.byteLength(outputMap, 'utf8')
|
|
1146
|
+
// }
|
|
1147
|
+
// }
|
|
1148
|
+
// }
|
|
1149
|
+
|
|
1124
1150
|
const {
|
|
1125
1151
|
globalObject,
|
|
1126
1152
|
chunkLoadingGlobal
|
|
@@ -1300,10 +1326,11 @@ try {
|
|
|
1300
1326
|
let insertBeforeIndex = -1
|
|
1301
1327
|
const info = typeLoaderProcessInfo[type]
|
|
1302
1328
|
loaders.forEach((loader, index) => {
|
|
1303
|
-
|
|
1329
|
+
const currentLoader = toPosix(loader.loader)
|
|
1330
|
+
if (currentLoader.includes(info[0])) {
|
|
1304
1331
|
loader.loader = info[1]
|
|
1305
|
-
|
|
1306
|
-
if (
|
|
1332
|
+
insertBeforeIndex = index
|
|
1333
|
+
} else if (currentLoader.includes(info[1])) {
|
|
1307
1334
|
insertBeforeIndex = index
|
|
1308
1335
|
}
|
|
1309
1336
|
})
|
|
@@ -1343,13 +1370,13 @@ try {
|
|
|
1343
1370
|
|
|
1344
1371
|
if (mpx.mode === 'web') {
|
|
1345
1372
|
const mpxStyleOptions = queryObj.mpxStyleOptions
|
|
1346
|
-
const firstLoader =
|
|
1373
|
+
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
1347
1374
|
const isPitcherRequest = firstLoader.includes('vue-loader/lib/loaders/pitcher')
|
|
1348
1375
|
let cssLoaderIndex = -1
|
|
1349
1376
|
let vueStyleLoaderIndex = -1
|
|
1350
1377
|
let mpxStyleLoaderIndex = -1
|
|
1351
1378
|
loaders.forEach((loader, index) => {
|
|
1352
|
-
const currentLoader = loader.loader
|
|
1379
|
+
const currentLoader = toPosix(loader.loader)
|
|
1353
1380
|
if (currentLoader.includes('css-loader')) {
|
|
1354
1381
|
cssLoaderIndex = index
|
|
1355
1382
|
} else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader')) {
|
|
@@ -1380,25 +1407,6 @@ try {
|
|
|
1380
1407
|
})
|
|
1381
1408
|
})
|
|
1382
1409
|
|
|
1383
|
-
compiler.hooks.emit.tap('MpxWebpackPlugin', (compilation) => {
|
|
1384
|
-
if (this.options.generateBuildMap) {
|
|
1385
|
-
const pagesMap = compilation.__mpx__.pagesMap
|
|
1386
|
-
const componentsPackageMap = compilation.__mpx__.componentsMap
|
|
1387
|
-
const componentsMap = Object.keys(componentsPackageMap).map(item => componentsPackageMap[item]).reduce((pre, cur) => {
|
|
1388
|
-
return { ...pre, ...cur }
|
|
1389
|
-
}, {})
|
|
1390
|
-
const outputMap = JSON.stringify({ ...pagesMap, ...componentsMap })
|
|
1391
|
-
compilation.assets['../outputMap.json'] = {
|
|
1392
|
-
source: () => {
|
|
1393
|
-
return outputMap
|
|
1394
|
-
},
|
|
1395
|
-
size: () => {
|
|
1396
|
-
return Buffer.byteLength(outputMap, 'utf8')
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
})
|
|
1401
|
-
|
|
1402
1410
|
const clearFileCache = () => {
|
|
1403
1411
|
const fs = compiler.intermediateFileSystem
|
|
1404
1412
|
const cacheLocation = compiler.options.cache.cacheLocation
|
|
@@ -16,7 +16,9 @@ module.exports = function loadPostcssConfig (loaderContext, inlineConfig = {}) {
|
|
|
16
16
|
webpack: loaderContext,
|
|
17
17
|
defs: inlineConfig.defs || {}
|
|
18
18
|
}
|
|
19
|
-
loaded = load(ctx, config.path, {
|
|
19
|
+
loaded = load(ctx, config.path, {
|
|
20
|
+
loaders: { '.json': (_, content) => JSON.parse(content) }
|
|
21
|
+
}).catch(err => {
|
|
20
22
|
// postcss-load-config throws error when no config file is found,
|
|
21
23
|
// but for us it's optional. only emit other errors
|
|
22
24
|
if (err.message.indexOf('No PostCSS Config found') >= 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.14",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=14.14.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "6490248041554fc3b6ffbe5a3acdb6f94d12331b"
|
|
84
84
|
}
|