@plaudit/webpack-extensions 3.7.0 → 3.8.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.8.0] - 2026-05-20
9
+ ### Added
10
+ - Support for the `module_dependencies` property on `script` assets
11
+ - This comes from version `2.91.0`
12
+
8
13
  ## [3.7.0] - 2026-05-04
9
14
  ### Added
10
15
  - PNPM 11 compatibility
@@ -117,6 +122,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
117
122
  - Legacy PostCSS features that have been integrated into modern CSS
118
123
  - `@extends` support
119
124
 
125
+ ## [2.91.0] - 2026-05-20
126
+ ### Added
127
+ - Support for the `module_dependencies` property on `script` assets
128
+
129
+ ## [2.90.1] - 2026-05-08
130
+ ### Fixed
131
+ - `postcss-loader` being a dev dependency
132
+
120
133
  ## [2.90.0] - 2026-05-04
121
134
  ### Added
122
135
  - PNPM 11 compatibility
@@ -1,7 +1,7 @@
1
1
  import { Compilation } from "webpack";
2
2
  import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
3
3
  import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
4
- import { ParsedAssetsJson, BlockEntrypointInfo, FileSegmentBlockEntrypointInfo, VerifiedAdvancedOutputConfig, ParsedAssetJsonProvider, ScriptArgsObject, InlinedAsset } from "../shared";
4
+ import { BlockEntrypointInfo, FileSegmentBlockEntrypointInfo, InlinedAsset, ParsedAssetJsonProvider, ParsedAssetsJson, ScriptArgsObject, VerifiedAdvancedOutputConfig } from "../shared";
5
5
  import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
6
6
  type WorkableBlockEntrypointInfo = Omit<FileSegmentBlockEntrypointInfo, 'originalValue' | 'pathQueryParameters'> & Partial<Pick<FileSegmentBlockEntrypointInfo, 'originalValue'>> & {
7
7
  outputPath: string;
@@ -237,21 +237,32 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
237
237
  }
238
238
  static convertToScriptHandles(handleData) {
239
239
  return handleData.map(hd => {
240
- const deps = hd.originalValue !== undefined ? hd.assetData.dependencies : [];
240
+ const { inlinedAsset, originalValue, outputPath, entrypointField, scriptArgsObject: rawScriptArgsObject, assetData, handle } = hd;
241
+ const { dependencies = [], module_dependencies = undefined } = originalValue !== undefined ? assetData : {};
241
242
  let scriptArgsObject;
242
- if (hd.scriptArgsObject !== undefined) {
243
- scriptArgsObject = hd.scriptArgsObject;
244
- }
245
- else if (hd.inlinedAsset !== undefined) {
246
- scriptArgsObject = hd.inlinedAsset.position === 'before' ? { strategy: "defer" } : undefined;
247
- }
248
- else if (!hd.entrypointField.startsWith("editor")) {
249
- scriptArgsObject = { strategy: "defer" };
243
+ if (rawScriptArgsObject !== undefined) {
244
+ scriptArgsObject = { ...rawScriptArgsObject, module_dependencies: (0, shared_1.mergeModuleDependencyArrays)(rawScriptArgsObject.module_dependencies, module_dependencies) };
250
245
  }
251
246
  else {
252
- scriptArgsObject = undefined;
247
+ if (inlinedAsset !== undefined) {
248
+ scriptArgsObject = inlinedAsset.position === 'before' ? { strategy: "defer" } : undefined;
249
+ }
250
+ else if (!entrypointField.startsWith("editor")) {
251
+ scriptArgsObject = { strategy: "defer" };
252
+ }
253
+ else {
254
+ scriptArgsObject = undefined;
255
+ }
256
+ if (module_dependencies?.length) {
257
+ if (scriptArgsObject === undefined) {
258
+ scriptArgsObject = { module_dependencies };
259
+ }
260
+ else {
261
+ scriptArgsObject.module_dependencies = module_dependencies;
262
+ }
263
+ }
253
264
  }
254
- return [hd.handle, { src: hd.outputPath, rest: scriptArgsObject !== undefined ? [deps, hd.assetData.version, scriptArgsObject] : [deps, hd.assetData.version], inlinedAsset: hd.inlinedAsset }];
265
+ return [handle, { src: outputPath, rest: scriptArgsObject !== undefined ? [dependencies, assetData.version, scriptArgsObject] : [dependencies, assetData.version], inlinedAsset }];
255
266
  });
256
267
  }
257
268
  static doFileOrHandleReplacements(compilation, blockJson, workableBlockEntrypointsInfo, getter) {
@@ -96,11 +96,12 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
96
96
  const isCss = (0, shared_1.isStyleField)(assetType);
97
97
  const handleGroup = isCss ? 'styleHandles'
98
98
  : ((0, shared_1.isScriptModuleField)(assetType) ? 'scriptModuleHandles' : 'scriptHandles');
99
+ const { dependencies, module_dependencies } = assetData;
99
100
  blockExtensionsConfig[handleGroup][handle] = {
100
101
  src: isCss ? assetPath.replace(/\.js$/, ".css") : assetPath,
101
102
  rest: isCss || key.startsWith("editor")
102
- ? [assetData.dependencies, assetData.version]
103
- : [assetData.dependencies, assetData.version, { strategy: 'defer' }]
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
105
  };
105
106
  (blockExtensionsConfig.blocks[blockSlug] ?? (blockExtensionsConfig.blocks[blockSlug] = {}))[key] = handle;
106
107
  }
@@ -297,11 +297,12 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
297
297
  const extension = (0, node_path_1.extname)(file).toLowerCase();
298
298
  const type = extension === ".js" ? 'script' : (extension === ".mjs" ? 'script_module' : 'style');
299
299
  const isScript = type !== 'style';
300
- const dependencies = isScript === entrypointChunkIsScript ? assetData.dependencies : [];
300
+ const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
301
301
  const { lazyLoader, locations } = this.dest;
302
302
  const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
303
303
  const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags));
304
- const rest = isScript && scriptArgsObject !== undefined ? [dependencies, assetData.version, scriptArgsObject] : [dependencies, assetData.version];
304
+ const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
305
+ const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
305
306
  const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
306
307
  handles.push({
307
308
  src: destPath,
package/dist/shared.d.ts CHANGED
@@ -4,15 +4,21 @@ import { type AssetInfo, type Compilation, type Configuration, type Entrypoint,
4
4
  import { SourceType } from "./utils/entrypoint-resolution-logic";
5
5
  import type { NormalizedEnqueuingControlFlags } from "./utils/path-query-and-related-helpers";
6
6
  export * from "./utils/entrypoint-resolution-logic";
7
+ export type WPModuleDependency = {
8
+ id: string;
9
+ import?: string;
10
+ };
7
11
  export type ParsedAssetsJson = Record<string, {
8
12
  dependencies: string[];
9
13
  version: string;
14
+ module_dependencies?: (string | WPModuleDependency)[];
10
15
  }>;
11
16
  export declare function isParsedAssetsJson(thing: any): thing is ParsedAssetsJson;
12
17
  export type ScriptArgsObject = {
13
18
  strategy?: 'defer' | 'async';
14
19
  in_footer?: boolean;
15
20
  fetchpriority?: 'auto' | 'low' | 'high';
21
+ module_dependencies?: (string | WPModuleDependency)[];
16
22
  };
17
23
  type BaseRestType = [/* dependencies: */ string[], /* version: */ string];
18
24
  export type InlinedAsset = {
@@ -212,6 +218,7 @@ export declare const styleExtension: RegExp;
212
218
  export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "script" | "style" | "";
213
219
  export declare function isStyleField(field: string): field is 'style' | 'viewStyle' | 'editorStyle';
214
220
  export declare function isScriptModuleField(field: string): field is 'viewScriptModule';
221
+ export declare function mergeModuleDependencyArrays(a: (string | WPModuleDependency)[] | undefined, b: (string | WPModuleDependency)[] | undefined): (string | WPModuleDependency)[] | undefined;
215
222
  export declare function getHandleGroup(field: string): 'styleHandles' | 'scriptHandles' | 'scriptModuleHandles';
216
223
  export type StripFirstTwoItems<A extends any[]> = A extends [any, any, ...rest: infer R] ? R : never;
217
224
  export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
package/dist/shared.js CHANGED
@@ -34,6 +34,7 @@ exports.leadingSlashIt = leadingSlashIt;
34
34
  exports.scriptOrStyleTest = scriptOrStyleTest;
35
35
  exports.isStyleField = isStyleField;
36
36
  exports.isScriptModuleField = isScriptModuleField;
37
+ exports.mergeModuleDependencyArrays = mergeModuleDependencyArrays;
37
38
  exports.getHandleGroup = getHandleGroup;
38
39
  exports.hasAtLeastOneItem = hasAtLeastOneItem;
39
40
  exports.arrayIsLength = arrayIsLength;
@@ -65,7 +66,7 @@ function isParsedAssetsJson(thing) {
65
66
  }
66
67
  for (const value of Object.values(thing)) {
67
68
  if ((!value || typeof value !== 'object') ||
68
- (!('dependencies' in value) || !Array.isArray(value.dependencies) || value.dependencies.some(d => typeof d !== 'string')) ||
69
+ (!('dependencies' in value) || !Array.isArray(value.dependencies) || (value.dependencies.length > 0 && !value.dependencies.every(d => typeof d === 'string' || (d && typeof d === 'object' && typeof d.id === 'string')))) ||
69
70
  (!('version' in value) || !value.version || typeof value.version !== 'string')) {
70
71
  return false;
71
72
  }
@@ -174,6 +175,34 @@ function isStyleField(field) {
174
175
  function isScriptModuleField(field) {
175
176
  return field.includes("odule");
176
177
  }
178
+ function mergeModuleDependencyArrays(a, b) {
179
+ if (a === undefined || a.length === 0) {
180
+ return b;
181
+ }
182
+ if (b === undefined || b.length === 0) {
183
+ return a;
184
+ }
185
+ const seenModuleDeps = new Map();
186
+ return [...a, ...b].filter(dep => {
187
+ let id, type;
188
+ if (typeof dep === 'string') {
189
+ id = dep;
190
+ type = 'static';
191
+ }
192
+ else {
193
+ id = dep.id;
194
+ type = dep.import ?? 'static';
195
+ }
196
+ if (seenModuleDeps.has(id)) {
197
+ if (type !== seenModuleDeps.get(id)) {
198
+ throw newCleanWebpackError(`Encountered conflicting import types for the "${id}" module dependency`);
199
+ }
200
+ return false;
201
+ }
202
+ seenModuleDeps.set(id, type);
203
+ return true;
204
+ });
205
+ }
177
206
  function getHandleGroup(field) {
178
207
  if (isStyleField(field)) {
179
208
  return 'styleHandles';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -28,9 +28,9 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@plaudit/gutenberg-api-extensions": "^2.97.0",
31
+ "@plaudit/gutenberg-api-extensions": "^2.97.1",
32
32
  "@types/browser-sync-webpack-plugin": "^2.2.5",
33
- "@types/node": "^25.6.0",
33
+ "@types/node": "^25.9.1",
34
34
  "@types/postcss-functions": "^4.0.4",
35
35
  "@types/postcss-import": "^14.0.3",
36
36
  "@types/tapable": "^2.3.0",
@@ -43,17 +43,17 @@
43
43
  "@plaudit/postcss-color-function": "^5.1.0",
44
44
  "@plaudit/postcss-strip-units": "^3.0.0",
45
45
  "@plaudit/postcss-variables": "^2.0.1",
46
- "@wordpress/dependency-extraction-webpack-plugin": "^6.45.0",
47
- "@wordpress/scripts": "^32.1.0",
46
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.46.0",
47
+ "@wordpress/scripts": "^32.2.0",
48
48
  "autoprefixer": "^10.5.0",
49
49
  "browser-sync": "^3.0.4",
50
50
  "copy-webpack-plugin": "10.2.4",
51
51
  "css-minimizer-webpack-plugin": "^8.0.0",
52
- "cssnano": "^7.1.8",
52
+ "cssnano": "^7.1.9",
53
53
  "fork-ts-checker-webpack-plugin": "^9.1.0",
54
54
  "http-proxy-middleware": "^3.0.5",
55
55
  "json2php": "^0.0.12",
56
- "postcss": "^8.5.13",
56
+ "postcss": "^8.5.15",
57
57
  "postcss-calc": "^10.1.1",
58
58
  "postcss-functions": "^4.0.2",
59
59
  "postcss-import": "^16.1.1",
@@ -63,7 +63,7 @@
63
63
  "postcss-property-lookup": "^3.0.0",
64
64
  "postcss-reporter": "^7.1.0",
65
65
  "postcss-url": "^10.1.3",
66
- "webpack": "^5.106.2",
66
+ "webpack": "^5.107.0",
67
67
  "webpack-remove-empty-scripts": "^1.1.1",
68
68
  "xml-formatter": "^3.7.0"
69
69
  },
@@ -71,7 +71,6 @@
71
71
  "node": ">=20"
72
72
  },
73
73
  "scripts": {
74
- "pnpm:devPreinstall": "pnpm add --config '@plaudit/pnpm-plugin-plaudit-config'",
75
74
  "build": "tsc",
76
75
  "clean": "rm -rf dist",
77
76
  "build:clean": "pnpm run clean && pnpm run build",