@plaudit/webpack-extensions 2.44.2 → 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];
|
|
@@ -495,7 +495,7 @@ function makeSync() {
|
|
|
495
495
|
});
|
|
496
496
|
return res;
|
|
497
497
|
}
|
|
498
|
-
function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey) {
|
|
498
|
+
function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey, usedHandles) {
|
|
499
499
|
if (!asset.startsWith("file:./")) {
|
|
500
500
|
return undefined;
|
|
501
501
|
}
|
|
@@ -507,8 +507,15 @@ function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey) {
|
|
|
507
507
|
if (!assetData) {
|
|
508
508
|
return undefined;
|
|
509
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
|
+
}
|
|
510
517
|
return [
|
|
511
|
-
isCss,
|
|
518
|
+
isCss, handle,
|
|
512
519
|
{ src, rest: isCss || mappableKey.startsWith("editor") ? [assetData.dependencies, assetData.version] : [assetData.dependencies, assetData.version, { strategy: 'defer' }] }
|
|
513
520
|
];
|
|
514
521
|
}
|