@plaudit/webpack-extensions 2.44.3 → 2.44.4
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.
|
@@ -171,7 +171,7 @@ class BlockJSONManagingPlugin {
|
|
|
171
171
|
const inputPath = node_path_1.default.normalize(node_path_1.default.join(sourceDir, value.substring(5)));
|
|
172
172
|
const outputAndAdditionalFiles = BlockJSONManagingPlugin.blockJsonToEntrypointsMap.get(name)?.get(inputPath);
|
|
173
173
|
if (outputAndAdditionalFiles !== undefined) {
|
|
174
|
-
const
|
|
174
|
+
const { output, additionalFiles } = outputAndAdditionalFiles;
|
|
175
175
|
const prefix = value.startsWith("./", 5) ? "./" : "";
|
|
176
176
|
const relativePath = node_path_1.default.relative(node_path_1.default.dirname(name), output.path);
|
|
177
177
|
const res = [`file:${prefix}${relativePath}`, output.hash];
|
|
@@ -303,10 +303,10 @@ class BlockJSONManagingPlugin {
|
|
|
303
303
|
const entryMeta = { hash: entrypointChunk.hash ?? destPath, path: destPath };
|
|
304
304
|
const currentEntrypoints = BlockJSONManagingPlugin.blockJsonToEntrypointsMap.get(name);
|
|
305
305
|
if (currentEntrypoints) {
|
|
306
|
-
currentEntrypoints.set(srcPath,
|
|
306
|
+
currentEntrypoints.set(srcPath, { output: entryMeta, additionalFiles });
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
309
|
-
BlockJSONManagingPlugin.blockJsonToEntrypointsMap.set(name, new Map([[srcPath,
|
|
309
|
+
BlockJSONManagingPlugin.blockJsonToEntrypointsMap.set(name, new Map([[srcPath, { output: entryMeta, additionalFiles }]]));
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -381,6 +381,12 @@ class BlockJSONManagingPlugin {
|
|
|
381
381
|
if (typeof rawAssetDataSource === 'string') {
|
|
382
382
|
const scriptHandles = {};
|
|
383
383
|
const styleHandles = {};
|
|
384
|
+
const additionalFilesMap = new Map([...BlockJSONManagingPlugin.blockJsonToEntrypointsMap.values()] // Extract the recorded block.json files into an array
|
|
385
|
+
.flatMap(epMap => [...epMap.values()]) // Extract the recorded entrypoints for all block.json files into a single array
|
|
386
|
+
.flatMap(epMapValue => {
|
|
387
|
+
return epMapValue.additionalFiles.map(af => [af, epMapValue.output.path]); // Pair each additionalFile with its progenitor
|
|
388
|
+
}) // Flatten the per-entrypoint [additionalFile, progenitor] pairs into a single array
|
|
389
|
+
);
|
|
384
390
|
const rawAssetData = JSON.parse(rawAssetDataSource);
|
|
385
391
|
const usedHandles = {};
|
|
386
392
|
for (const [blockFolder, config] of blockDirConfigs) {
|
|
@@ -389,7 +395,7 @@ class BlockJSONManagingPlugin {
|
|
|
389
395
|
if (cfg) {
|
|
390
396
|
if (Array.isArray(cfg)) {
|
|
391
397
|
for (let i = 0; i < cfg.length; i++) {
|
|
392
|
-
const assetDetails = getAssetDetails(blockFolder, cfg[i], rawAssetData, mappableKey, usedHandles);
|
|
398
|
+
const assetDetails = getAssetDetails(blockFolder, cfg[i], rawAssetData, additionalFilesMap, mappableKey, usedHandles);
|
|
393
399
|
if (assetDetails) {
|
|
394
400
|
(assetDetails[0] ? styleHandles : scriptHandles)[assetDetails[1]] = assetDetails[2];
|
|
395
401
|
cfg[i] = assetDetails[1];
|
|
@@ -397,7 +403,7 @@ class BlockJSONManagingPlugin {
|
|
|
397
403
|
}
|
|
398
404
|
}
|
|
399
405
|
else {
|
|
400
|
-
const assetDetails = getAssetDetails(blockFolder, cfg, rawAssetData, mappableKey, usedHandles);
|
|
406
|
+
const assetDetails = getAssetDetails(blockFolder, cfg, rawAssetData, additionalFilesMap, mappableKey, usedHandles);
|
|
401
407
|
if (assetDetails) {
|
|
402
408
|
(assetDetails[0] ? styleHandles : scriptHandles)[assetDetails[1]] = assetDetails[2];
|
|
403
409
|
config[mappableKey] = assetDetails[1];
|
|
@@ -495,15 +501,21 @@ function makeSync() {
|
|
|
495
501
|
});
|
|
496
502
|
return res;
|
|
497
503
|
}
|
|
498
|
-
function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey, usedHandles) {
|
|
504
|
+
function getAssetDetails(blockFolder, asset, rawAssetData, additionalFilesMap, mappableKey, usedHandles) {
|
|
499
505
|
if (!asset.startsWith("file:./")) {
|
|
500
506
|
return undefined;
|
|
501
507
|
}
|
|
502
508
|
const src = `${blockFolder}/${asset.substring(7)}`;
|
|
503
509
|
const isCss = src.endsWith(".css");
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
510
|
+
let assetData;
|
|
511
|
+
const lookupSrc = additionalFilesMap.get(src);
|
|
512
|
+
if (lookupSrc) {
|
|
513
|
+
const tempAssetData = getAssetDataAccountingForCSS(lookupSrc, rawAssetData);
|
|
514
|
+
assetData = tempAssetData ? { ...tempAssetData, dependencies: [] } : undefined;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
assetData = getAssetDataAccountingForCSS(src, rawAssetData);
|
|
518
|
+
}
|
|
507
519
|
if (!assetData) {
|
|
508
520
|
return undefined;
|
|
509
521
|
}
|
|
@@ -519,3 +531,13 @@ function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey, usedHand
|
|
|
519
531
|
{ src, rest: isCss || mappableKey.startsWith("editor") ? [assetData.dependencies, assetData.version] : [assetData.dependencies, assetData.version, { strategy: 'defer' }] }
|
|
520
532
|
];
|
|
521
533
|
}
|
|
534
|
+
function getAssetDataAccountingForCSS(src, rawAssetData) {
|
|
535
|
+
if (rawAssetData[src]) {
|
|
536
|
+
return rawAssetData[src];
|
|
537
|
+
}
|
|
538
|
+
if (src.endsWith(".css")) {
|
|
539
|
+
return rawAssetData[src.substring(0, src.length - 3) + "js"] // A simple style dependency that isn't named "style"
|
|
540
|
+
?? rawAssetData[src.substring(0, src.length - 3).replace("style-style", "style") + "js"]; // A simple style dependency that IS named style
|
|
541
|
+
}
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|