@plaudit/webpack-extensions 2.44.4 → 2.44.5
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.
|
@@ -294,19 +294,30 @@ class BlockJSONManagingPlugin {
|
|
|
294
294
|
continue;
|
|
295
295
|
}
|
|
296
296
|
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
const runtimeName = entrypointChunk.name;
|
|
298
|
+
let additionalFiles;
|
|
299
|
+
if (runtimeName) {
|
|
300
|
+
additionalFiles = new Set([...compilation.chunks]
|
|
301
|
+
.filter(chunk => typeof chunk.runtime === 'string' ? chunk.runtime === entrypointChunk.name : chunk.runtime?.has(runtimeName))
|
|
302
|
+
.flatMap(chunk => [...chunk.files])
|
|
303
|
+
.filter(file => !file.endsWith(".asset.php")));
|
|
304
|
+
additionalFiles.delete(destPath);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
additionalFiles = new Set();
|
|
308
|
+
for (const entrypointChunkFile of entrypointChunk.files) {
|
|
309
|
+
if (!entrypointChunkFile.endsWith(".asset.php") && entrypointChunkFile !== destPath) {
|
|
310
|
+
additionalFiles.add(entrypointChunkFile);
|
|
311
|
+
}
|
|
301
312
|
}
|
|
302
313
|
}
|
|
303
314
|
const entryMeta = { hash: entrypointChunk.hash ?? destPath, path: destPath };
|
|
304
315
|
const currentEntrypoints = BlockJSONManagingPlugin.blockJsonToEntrypointsMap.get(name);
|
|
305
316
|
if (currentEntrypoints) {
|
|
306
|
-
currentEntrypoints.set(srcPath, { output: entryMeta, additionalFiles });
|
|
317
|
+
currentEntrypoints.set(srcPath, { output: entryMeta, additionalFiles: [...additionalFiles] });
|
|
307
318
|
}
|
|
308
319
|
else {
|
|
309
|
-
BlockJSONManagingPlugin.blockJsonToEntrypointsMap.set(name, new Map([[srcPath, { output: entryMeta, additionalFiles }]]));
|
|
320
|
+
BlockJSONManagingPlugin.blockJsonToEntrypointsMap.set(name, new Map([[srcPath, { output: entryMeta, additionalFiles: [...additionalFiles] }]]));
|
|
310
321
|
}
|
|
311
322
|
}
|
|
312
323
|
}
|
|
@@ -388,6 +399,14 @@ class BlockJSONManagingPlugin {
|
|
|
388
399
|
}) // Flatten the per-entrypoint [additionalFile, progenitor] pairs into a single array
|
|
389
400
|
);
|
|
390
401
|
const rawAssetData = JSON.parse(rawAssetDataSource);
|
|
402
|
+
for (const chunk of compilation.chunks) {
|
|
403
|
+
if (compilation.chunkGraph.getChunkModulesIterableBySourceType(chunk, 'css/mini-extract')) {
|
|
404
|
+
const output = [...chunk.files].find(f => f.endsWith(".css"));
|
|
405
|
+
if (output) {
|
|
406
|
+
rawAssetData[output] = { dependencies: [], version: chunk.contentHash['css/mini-extract'] ?? chunk.hash ?? "" };
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
391
410
|
const usedHandles = {};
|
|
392
411
|
for (const [blockFolder, config] of blockDirConfigs) {
|
|
393
412
|
for (const mappableKey of BlockJSONManagingPlugin.mappableKeys) {
|
|
@@ -508,13 +527,18 @@ function getAssetDetails(blockFolder, asset, rawAssetData, additionalFilesMap, m
|
|
|
508
527
|
const src = `${blockFolder}/${asset.substring(7)}`;
|
|
509
528
|
const isCss = src.endsWith(".css");
|
|
510
529
|
let assetData;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
const tempAssetData = getAssetDataAccountingForCSS(lookupSrc, rawAssetData);
|
|
514
|
-
assetData = tempAssetData ? { ...tempAssetData, dependencies: [] } : undefined;
|
|
530
|
+
if (rawAssetData[src]) {
|
|
531
|
+
assetData = rawAssetData[src];
|
|
515
532
|
}
|
|
516
533
|
else {
|
|
517
|
-
|
|
534
|
+
const lookupSrc = additionalFilesMap.get(src);
|
|
535
|
+
if (lookupSrc) {
|
|
536
|
+
const tempAssetData = getAssetDataAccountingForCSS(lookupSrc, rawAssetData);
|
|
537
|
+
assetData = tempAssetData ? { ...tempAssetData, dependencies: [] } : undefined;
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
assetData = getAssetDataAccountingForCSS(src, rawAssetData);
|
|
541
|
+
}
|
|
518
542
|
}
|
|
519
543
|
if (!assetData) {
|
|
520
544
|
return undefined;
|
|
@@ -513,6 +513,24 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
513
513
|
publicPath: publicPath,
|
|
514
514
|
library: outputLibrary
|
|
515
515
|
},
|
|
516
|
+
optimization: {
|
|
517
|
+
...webpackConfig.optimization,
|
|
518
|
+
splitChunks: {
|
|
519
|
+
cacheGroups: {
|
|
520
|
+
style: {
|
|
521
|
+
// This is a flagrant abuse of cache groups, but it fixes a persistent problem wherein the dependencies and versions of scripts and styles were bleeding into each-other
|
|
522
|
+
type: 'css/mini-extract',
|
|
523
|
+
chunks: 'all',
|
|
524
|
+
enforce: true,
|
|
525
|
+
name(_, chunks, cacheGroupKey) {
|
|
526
|
+
const chunkName = chunks.find(chunk => chunk.name)?.name;
|
|
527
|
+
return chunkName.includes("script") ? `${node_path_1.default.dirname(chunkName)}/${cacheGroupKey}-${node_path_1.default.basename(chunkName)}` : chunkName;
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
default: false,
|
|
531
|
+
},
|
|
532
|
+
}
|
|
533
|
+
},
|
|
516
534
|
module: {
|
|
517
535
|
...webpackConfig.module,
|
|
518
536
|
rules: fixedRules
|