@plaudit/webpack-extensions 2.44.1 → 2.44.3
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.
|
@@ -3,7 +3,7 @@ export default class BlockJSONManagingPlugin implements WebpackPluginInstance {
|
|
|
3
3
|
private readonly standaloneBlocks;
|
|
4
4
|
private readonly processingModules;
|
|
5
5
|
static readonly mappableModuleKeys: readonly ["viewScriptModule", "scriptModule"];
|
|
6
|
-
static readonly mappableNonModuleKeys: readonly ["
|
|
6
|
+
static readonly mappableNonModuleKeys: readonly ["editorScript", "script", "viewScript", "editorStyle", "style", "viewStyle"];
|
|
7
7
|
private static readonly styleExtensionPattern;
|
|
8
8
|
private static readonly scriptExtensionPattern;
|
|
9
9
|
private static readonly mappableKeys;
|
|
@@ -12,7 +12,7 @@ class BlockJSONManagingPlugin {
|
|
|
12
12
|
standaloneBlocks;
|
|
13
13
|
processingModules;
|
|
14
14
|
static mappableModuleKeys = ["viewScriptModule", "scriptModule"];
|
|
15
|
-
static mappableNonModuleKeys = ["
|
|
15
|
+
static mappableNonModuleKeys = ["editorScript", "script", "viewScript", "editorStyle", "style", "viewStyle"];
|
|
16
16
|
static styleExtensionPattern = /\.(p?c|sa)ss$/i;
|
|
17
17
|
static scriptExtensionPattern = /\.m?[tj]sx?$/i;
|
|
18
18
|
static mappableKeys = [...BlockJSONManagingPlugin.mappableNonModuleKeys, ...BlockJSONManagingPlugin.mappableModuleKeys];
|
|
@@ -382,14 +382,14 @@ class BlockJSONManagingPlugin {
|
|
|
382
382
|
const scriptHandles = {};
|
|
383
383
|
const styleHandles = {};
|
|
384
384
|
const rawAssetData = JSON.parse(rawAssetDataSource);
|
|
385
|
-
const
|
|
385
|
+
const usedHandles = {};
|
|
386
386
|
for (const [blockFolder, config] of blockDirConfigs) {
|
|
387
|
-
for (const mappableKey of mappableKeys) {
|
|
387
|
+
for (const mappableKey of BlockJSONManagingPlugin.mappableKeys) {
|
|
388
388
|
const cfg = config[mappableKey];
|
|
389
389
|
if (cfg) {
|
|
390
390
|
if (Array.isArray(cfg)) {
|
|
391
391
|
for (let i = 0; i < cfg.length; i++) {
|
|
392
|
-
const assetDetails = getAssetDetails(blockFolder, cfg[i], rawAssetData, mappableKey);
|
|
392
|
+
const assetDetails = getAssetDetails(blockFolder, cfg[i], rawAssetData, mappableKey, usedHandles);
|
|
393
393
|
if (assetDetails) {
|
|
394
394
|
(assetDetails[0] ? styleHandles : scriptHandles)[assetDetails[1]] = assetDetails[2];
|
|
395
395
|
cfg[i] = assetDetails[1];
|
|
@@ -397,7 +397,7 @@ class BlockJSONManagingPlugin {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
else {
|
|
400
|
-
const assetDetails = getAssetDetails(blockFolder, cfg, rawAssetData, mappableKey);
|
|
400
|
+
const assetDetails = getAssetDetails(blockFolder, cfg, rawAssetData, mappableKey, usedHandles);
|
|
401
401
|
if (assetDetails) {
|
|
402
402
|
(assetDetails[0] ? styleHandles : scriptHandles)[assetDetails[1]] = assetDetails[2];
|
|
403
403
|
config[mappableKey] = assetDetails[1];
|
|
@@ -421,9 +421,8 @@ class BlockJSONManagingPlugin {
|
|
|
421
421
|
compilation.emitAsset("blockdir.config.php", new webpack_1.sources.RawSource("<?php return "
|
|
422
422
|
+ json_to_php_but_with____injection_1.default.make({ indent: "\t", linebreak: "\n", shortArraySyntax: true })(sortedBlockDirConfigData, "")
|
|
423
423
|
.replaceAll(/(\n\t*)\[\s+],/gs, "$1[],")
|
|
424
|
-
.replaceAll(/\[\n\t+([^\n]+)\n\t+]/gs,
|
|
424
|
+
.replaceAll(/\[\n\t+([^\n]+)\n\t+]/gs, (_, inner) => `[${inner.trim()}]`)
|
|
425
425
|
.replaceAll(/'rest' => \[\n\t+(\[(?:'[^']+')?]),\n\t+('[^']+')(?:,\n\t+(\[[^\n]+]))?\n\t+]/gs, (_, deps, hash, args) => `'rest' => [${[deps, hash, args].filter(value => !!value).join(", ")}]`)
|
|
426
|
-
.replaceAll(/\[\t+]/gs, "[]")
|
|
427
426
|
+ ";"));
|
|
428
427
|
});
|
|
429
428
|
}
|
|
@@ -496,7 +495,7 @@ function makeSync() {
|
|
|
496
495
|
});
|
|
497
496
|
return res;
|
|
498
497
|
}
|
|
499
|
-
function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey) {
|
|
498
|
+
function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey, usedHandles) {
|
|
500
499
|
if (!asset.startsWith("file:./")) {
|
|
501
500
|
return undefined;
|
|
502
501
|
}
|
|
@@ -508,8 +507,15 @@ function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey) {
|
|
|
508
507
|
if (!assetData) {
|
|
509
508
|
return undefined;
|
|
510
509
|
}
|
|
510
|
+
let handle = src.substring(0, src.length - (isCss ? 4 : 3));
|
|
511
|
+
if (usedHandles[handle] !== undefined) {
|
|
512
|
+
handle += "-" + (++usedHandles[handle]);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
usedHandles[handle] = 0;
|
|
516
|
+
}
|
|
511
517
|
return [
|
|
512
|
-
isCss,
|
|
518
|
+
isCss, handle,
|
|
513
519
|
{ src, rest: isCss || mappableKey.startsWith("editor") ? [assetData.dependencies, assetData.version] : [assetData.dependencies, assetData.version, { strategy: 'defer' }] }
|
|
514
520
|
];
|
|
515
521
|
}
|