@plaudit/webpack-extensions 2.91.0 → 2.92.1

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.
package/CHANGELOG.md CHANGED
@@ -60,6 +60,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
60
60
  - Legacy PostCSS features that have been integrated into modern CSS
61
61
  - `@extends` support
62
62
 
63
+ ## [2.92.1] - 2026-05-21
64
+ ### Fixed
65
+ - Compatibility issues with module-mode building
66
+ - `module_dependencies` being set to `null` instead of being omitted
67
+
68
+ ## [2.92.0] - 2026-05-20
69
+ ### Added
70
+ - Support for marking `block.json` attributes with `"supports-bindings": true` to enable block binding support in the editor
71
+
63
72
  ## [2.91.0] - 2026-05-20
64
73
  ### Added
65
74
  - Support for the `module_dependencies` property on `script` assets
@@ -155,6 +155,33 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
155
155
  this.callRegisterFunction('script', writer, baseUriVar, Object.entries(finalizedScriptHandles));
156
156
  this.callRegisterFunction('style', writer, baseUriVar, Object.entries(finalizedStyleHandles));
157
157
  this.callRegisterFunction('script_module', writer, baseUriVar, Object.entries(metadata.scriptModuleHandles));
158
+ const entries = Object.entries(metadata.bindableBlockAttributes);
159
+ const supportedAttributes = new expressions_1.Var("supported_block_attributes", "?array");
160
+ if ((0, shared_1.arrayIsLength)(entries, 1)) {
161
+ writer.filter(`block_bindings_supported_attributes_${entries[0][0]}`, writer => {
162
+ const parameters = entries[0][1];
163
+ if (parameters.length === 1) {
164
+ writer.appendExpr(new expressions_1.Assignment(supportedAttributes, parameters[0], true));
165
+ }
166
+ else {
167
+ writer.call("array_push", [supportedAttributes, ...parameters]);
168
+ }
169
+ writer.return(supportedAttributes);
170
+ }, { functionArgParameters: [supportedAttributes] });
171
+ }
172
+ else if (entries.length > 1) {
173
+ const compiledBindingSupportingAttributes = new expressions_1.Var("compiled_binding_supporting_attributes");
174
+ writer.assign(compiledBindingSupportingAttributes, metadata.bindableBlockAttributes);
175
+ const blockType = new expressions_1.Var("block_type", "?string");
176
+ writer.filter(`block_bindings_supported_attributes`, writer => {
177
+ writer
178
+ .if(expressions_1.Op.binary(new expressions_1.Call("empty", [blockType]), " || ", new expressions_1.Call("empty", [new expressions_1.ArrayAccess(compiledBindingSupportingAttributes, blockType)])))
179
+ .return(supportedAttributes)
180
+ .endIf()
181
+ .call("array_push", [supportedAttributes, new expressions_1.Op("...", new expressions_1.ArrayAccess(compiledBindingSupportingAttributes, blockType))])
182
+ .return(supportedAttributes);
183
+ }, { functionArgParameters: [supportedAttributes, blockType], useVars: [compiledBindingSupportingAttributes] });
184
+ }
158
185
  writer.call("\\Plaudit\\Common\\ACF\\BlockManager::autoloadSubfoldersV3", [
159
186
  expressions_1.Constants.__DIR__, // string $dir
160
187
  new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)(blockData, false, "\t")), // array $blockdirConfig
@@ -185,6 +212,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
185
212
  .flatMap(bi => bi.workableBlockEntrypointsInfo)
186
213
  .sort((a, b) => a.handle.localeCompare(b.handle) || a.entrypointField.localeCompare(b.entrypointField));
187
214
  const blockData = {};
215
+ const bindableBlockAttributes = {};
188
216
  for (const [blockJsonAssetName, { sourcePath: blockJsonSourcePath, workableBlockEntrypointsInfo, blockJsonText }] of Object.entries(collatedWorkableBlockInfo)) {
189
217
  if (!blockJsonSourcePath) {
190
218
  compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`${blockJsonAssetName} does not have a source path`, blockJsonAssetName));
@@ -208,6 +236,19 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
208
236
  else {
209
237
  blockJson["version"] = hashForVersion;
210
238
  }
239
+ if (typeof blockJson["name"] === 'string' && typeof blockJson["attributes"] === 'object' && blockJson["attributes"]) {
240
+ for (const [name, attr] of Object.entries(blockJson["attributes"])) {
241
+ if (attr["supports-bindings"]) {
242
+ delete attr["supports-bindings"];
243
+ if (bindableBlockAttributes[blockJson["name"]] !== undefined) {
244
+ bindableBlockAttributes[blockJson["name"]].push(name);
245
+ }
246
+ else {
247
+ bindableBlockAttributes[blockJson["name"]] = [name];
248
+ }
249
+ }
250
+ }
251
+ }
211
252
  EnhancedBlockJSONPlugin.normalizeRenderTemplate(blockJson, pathsNeedRemapping, sourceDir, outputDir, compilation);
212
253
  const blockDirName = (0, node_path_1.dirname)((0, node_path_1.relative)(this.dest.destination, blockJsonAssetName));
213
254
  blockData[blockDirName] = EnhancedBlockJSONPlugin
@@ -226,7 +267,8 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
226
267
  styleHandles: Object.fromEntries(handleData.filter(hd => (0, shared_1.isStyleField)(hd.entrypointField))
227
268
  .map(hd => {
228
269
  return [hd.handle, { src: hd.outputPath, rest: [hd.originalValue !== undefined ? hd.assetData.dependencies : [], hd.assetData.version], inlinedAsset: hd.inlinedAsset }];
229
- }))
270
+ })),
271
+ bindableBlockAttributes
230
272
  },
231
273
  ...Object.fromEntries(Object.entries(blockData).sort((a, b) => a[0].localeCompare(b[0])))
232
274
  };
@@ -241,7 +283,8 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
241
283
  const { dependencies = [], module_dependencies = undefined } = originalValue !== undefined ? assetData : {};
242
284
  let scriptArgsObject;
243
285
  if (rawScriptArgsObject !== undefined) {
244
- scriptArgsObject = { ...rawScriptArgsObject, module_dependencies: (0, shared_1.mergeModuleDependencyArrays)(rawScriptArgsObject.module_dependencies, module_dependencies) };
286
+ const merged_module_dependencies = (0, shared_1.mergeModuleDependencyArrays)(rawScriptArgsObject.module_dependencies, module_dependencies);
287
+ scriptArgsObject = merged_module_dependencies?.length ? { ...rawScriptArgsObject, module_dependencies: merged_module_dependencies } : { ...rawScriptArgsObject };
245
288
  }
246
289
  else {
247
290
  if (inlinedAsset !== undefined) {
@@ -101,7 +101,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
101
101
  src: isCss ? assetPath.replace(/\.js$/, ".css") : assetPath,
102
102
  rest: isCss || key.startsWith("editor")
103
103
  ? (module_dependencies?.length ? [dependencies, assetData.version, { in_footer: true, module_dependencies }] : [dependencies, assetData.version])
104
- : [dependencies, assetData.version, { strategy: 'defer', module_dependencies: module_dependencies?.length ? module_dependencies : undefined }]
104
+ : [dependencies, assetData.version, module_dependencies?.length ? { strategy: 'defer', module_dependencies } : { strategy: 'defer' }]
105
105
  };
106
106
  (blockExtensionsConfig.blocks[blockSlug] ?? (blockExtensionsConfig.blocks[blockSlug] = {}))[key] = handle;
107
107
  }
@@ -139,7 +139,7 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
139
139
  const blockJsonChunkName = (0, node_path_1.join)(dest.destination, (0, node_path_1.relative)(srcRoot, dir), "block");
140
140
  const filesRegisteredByJson = [];
141
141
  const presentEntrypoints = (await Promise.all(entrypointFields
142
- .filter(entrypointField => entrypointField in blockJson)
142
+ .filter(entrypointField => (0, shared_1.isScriptModuleField)(entrypointField) === processingModules && entrypointField in blockJson)
143
143
  .flatMap(entrypointField => {
144
144
  return (Array.isArray(blockJson[entrypointField]) ? blockJson[entrypointField] : [blockJson[entrypointField]])
145
145
  .filter(originalValue => typeof originalValue === 'string')
@@ -181,6 +181,9 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
181
181
  continue;
182
182
  }
183
183
  const { type, locations, flags } = parsedFilename;
184
+ if (((type === 'script-module') !== processingModules)) {
185
+ continue;
186
+ }
184
187
  let entrypointField;
185
188
  if (Object.keys(locations).length === 2) {
186
189
  if (type === 'script-module') {
@@ -486,6 +486,9 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
486
486
  const { bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize } = currentBatch[0].dest;
487
487
  const { plugins, removeEmptyScriptsPlugin, makeAdditionalDependencyInjectorPlugin } = buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGlobalizedPlauditLibraries, externalize);
488
488
  handleDisablingTSCheckerIfNecessary(currentBatch.flatMap(a => a.srcRoots), scriptExtension, plugins);
489
+ const applicableExtensionTest = (name) => {
490
+ return commonConfig.scriptExtension.test(name) || (!processingModules && shared_1.styleExtension.test(name));
491
+ };
489
492
  const contextPath = webpackConfig.context ?? process.cwd();
490
493
  for (const { dest, src, srcIsDirectory, srcRoot } of currentBatch) {
491
494
  let plugin;
@@ -511,7 +514,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
511
514
  continue;
512
515
  }
513
516
  if (dirent.isFile()) {
514
- if ((commonConfig.scriptExtension.test(dirent.name) || shared_1.styleExtension.test(dirent.name))) {
517
+ if (applicableExtensionTest(dirent.name)) {
515
518
  const absoluteSrc = (0, common_config_helpers_1.joinPossiblyAbsolutePaths)(srcRoot, dirent.name);
516
519
  const extensionId = (0, node_path_1.parse)(dirent.name).name;
517
520
  rawEntrypoints.push([(0, node_path_1.join)(dest.destination, (0, node_path_1.basename)(absoluteSrc, (0, node_path_1.extname)(absoluteSrc))), {
@@ -521,7 +524,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
521
524
  }
522
525
  }
523
526
  else if (dirent.isDirectory()) {
524
- rawEntrypoints.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, [dirent.name]));
527
+ rawEntrypoints.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, applicableExtensionTest, [dirent.name]));
525
528
  }
526
529
  }
527
530
  return Object.fromEntries(rawEntrypoints);
@@ -533,10 +536,8 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
533
536
  }
534
537
  else if (sourceType === "plain" /* SourceType.plain */) {
535
538
  const absoluteSrc = typeof srcRoot === 'string' ? srcRoot : srcRoot[0];
536
- if (!srcIsDirectory) {
537
- if (!scriptExtension.test(absoluteSrc) && !shared_1.styleExtension.test(absoluteSrc)) {
538
- continue;
539
- }
539
+ if (!srcIsDirectory && !applicableExtensionTest(absoluteSrc)) {
540
+ continue;
540
541
  }
541
542
  const baseDest = stripExtension(dest.destination);
542
543
  if (config.plainEntrypointsVersion > 1) {
@@ -574,13 +575,16 @@ function processIndividualWebpackConfig(config, webpackConfig, sources, canClean
574
575
  return (0, common_config_helpers_1.commonMakeWebpackConfig)(config, commonConfig, webpackConfig, externalize, plugins, canClean && batches.length < 2);
575
576
  }).filter(cfg => cfg !== undefined);
576
577
  }
577
- async function walkExtensionsTree(srcRoot, dest, parents) {
578
+ async function walkExtensionsTree(srcRoot, dest, applicableExtensionTest, parents) {
578
579
  const res = [];
579
580
  for await (const dirent of await (0, promises_1.opendir)(srcRoot)) {
580
581
  if (dirent.name.startsWith("~")) {
581
582
  continue;
582
583
  }
583
584
  if (dirent.isFile()) {
585
+ if (!applicableExtensionTest(dirent.name)) {
586
+ continue;
587
+ }
584
588
  const parsedFilename = (0, location_encoding_filename_parser_1.parseLocationEncodingFilename)(dirent.name);
585
589
  if (parsedFilename === undefined) {
586
590
  continue;
@@ -608,7 +612,7 @@ async function walkExtensionsTree(srcRoot, dest, parents) {
608
612
  }]);
609
613
  }
610
614
  else if (dirent.isDirectory()) {
611
- res.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, [...parents, dirent.name]));
615
+ res.push(...await walkExtensionsTree((0, node_path_1.join)(srcRoot, dirent.name), dest, applicableExtensionTest, [...parents, dirent.name]));
612
616
  }
613
617
  }
614
618
  return res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.91.0",
3
+ "version": "2.92.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -66,8 +66,8 @@
66
66
  "postcss-property-lookup": "^3.0.0",
67
67
  "postcss-reporter": "^7.1.0",
68
68
  "postcss-simple-vars": "^7.0.1",
69
- "postcss-url": "^10.1.3",
70
- "webpack": "^5.107.0",
69
+ "postcss-url": "^10.1.4",
70
+ "webpack": "^5.107.1",
71
71
  "webpack-remove-empty-scripts": "^1.1.1",
72
72
  "xml-formatter": "^3.7.0"
73
73
  },