@plaudit/webpack-extensions 2.43.2 → 2.44.0

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.
@@ -389,7 +389,7 @@ class BlockJSONManagingPlugin {
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);
392
+ const assetDetails = getAssetDetails(blockFolder, cfg[i], rawAssetData, mappableKey);
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);
400
+ const assetDetails = getAssetDetails(blockFolder, cfg, rawAssetData, mappableKey);
401
401
  if (assetDetails) {
402
402
  (assetDetails[0] ? styleHandles : scriptHandles)[assetDetails[1]] = assetDetails[2];
403
403
  config[mappableKey] = assetDetails[1];
@@ -407,7 +407,7 @@ class BlockJSONManagingPlugin {
407
407
  }
408
408
  }
409
409
  sortedBlockDirConfigData = Object.fromEntries([
410
- ["__metadata", { version: 2, ...Object.fromEntries(this.additionalMetadata.entries()), scriptHandles, styleHandles }],
410
+ ["__metadata", { version: 3, ...Object.fromEntries(this.additionalMetadata.entries()), scriptHandles, styleHandles }],
411
411
  ...blockDirConfigs.map(entry => [entry[0], Object.fromEntries(Object.entries(entry[1]).filter(e => e[0] !== '$schema'))])
412
412
  ]);
413
413
  compilation.deleteAsset("assets.json");
@@ -421,7 +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(/'rest' => \[\n\t+\[],\n\t+('[^']+')\n\t+]/gs, "'rest' => [[], $1]")
424
+ .replaceAll(/\[\n\t+([^\n]+)\n\t+]/gs, "[$1]")
425
+ .replaceAll(/'rest' => \[\n\t+(\[(?:'[^']+')?]),\n\t+('[^']+')(?:,\n\t+(\[[^\n]+]))?\n\t+]/gs, (_, deps, hash, args) => `'rest' => [${[deps, hash, args].filter(value => !!value).join(", ")}]`)
425
426
  + ";"));
426
427
  });
427
428
  }
@@ -494,7 +495,7 @@ function makeSync() {
494
495
  });
495
496
  return res;
496
497
  }
497
- function getAssetDetails(blockFolder, asset, rawAssetData) {
498
+ function getAssetDetails(blockFolder, asset, rawAssetData, mappableKey) {
498
499
  if (!asset.startsWith("file:./")) {
499
500
  return undefined;
500
501
  }
@@ -506,5 +507,8 @@ function getAssetDetails(blockFolder, asset, rawAssetData) {
506
507
  if (!assetData) {
507
508
  return undefined;
508
509
  }
509
- return [isCss, src.substring(0, src.length - (isCss ? 4 : 3)), { src, rest: [assetData.dependencies, assetData.version] }];
510
+ return [
511
+ isCss, src.substring(0, src.length - (isCss ? 4 : 3)),
512
+ { src, rest: isCss || mappableKey.startsWith("editor") ? [assetData.dependencies, assetData.version] : [assetData.dependencies, assetData.version, { strategy: 'defer' }] }
513
+ ];
510
514
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.43.2",
3
+ "version": "2.44.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "/build"