@plaudit/webpack-extensions 3.6.3 → 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,16 @@ 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
+
13
+ ## [3.7.0] - 2026-05-04
14
+ ### Added
15
+ - PNPM 11 compatibility
16
+ - This comes from version `2.90.0`
17
+
8
18
  ## [3.6.3] - 2026-04-27
9
19
  ### Fixed
10
20
  - An `ENOENT` error when the `srcDir` does not map to an actual directory on disk
@@ -112,6 +122,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112
122
  - Legacy PostCSS features that have been integrated into modern CSS
113
123
  - `@extends` support
114
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
+
133
+ ## [2.90.0] - 2026-05-04
134
+ ### Added
135
+ - PNPM 11 compatibility
136
+
115
137
  ## [2.89.2] - 2026-04-27
116
138
  ### Fixed
117
139
  - An `ENOENT` error when the `srcDir` does not map to an actual directory on disk
@@ -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) {
@@ -1,41 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.ExtensionsConfigFileGeneratorPlugin = void 0;
37
4
  const promises_1 = require("node:fs/promises");
38
- const node_path_1 = __importStar(require("node:path"));
5
+ const node_path_1 = require("node:path");
39
6
  const php_writer_1 = require("@plaudit/php-writer");
40
7
  const expressions_1 = require("@plaudit/php-writer/expressions");
41
8
  const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
@@ -66,10 +33,10 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
66
33
  const emissionPromises = [];
67
34
  for await (const { name: setupFilePath } of await (0, promises_1.opendir)(this.extensionsSrcPath, { encoding: 'utf-8' })) {
68
35
  if (setupFilePath.endsWith("-setup.php")) {
69
- const setupFileSourcePath = node_path_1.default.join(this.extensionsSrcPath, setupFilePath);
36
+ const setupFileSourcePath = (0, node_path_1.join)(this.extensionsSrcPath, setupFilePath);
70
37
  compilation.fileDependencies.add(setupFileSourcePath);
71
38
  emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
72
- compilation.emitAsset(node_path_1.default.join(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
39
+ compilation.emitAsset((0, node_path_1.join)(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
73
40
  const blockSlug = /^(.+?)-setup.php$/i.exec(setupFilePath)?.[1];
74
41
  return [blockSlug, setupFilePath];
75
42
  }));
@@ -91,10 +58,10 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
91
58
  if (dirent.isFile()) {
92
59
  if (dirent.name === "setup.php") {
93
60
  const setupFilePath = (0, node_path_1.join)(...parents, dirent.name);
94
- const setupFileSourcePath = node_path_1.default.join(this.extensionsSrcPath, setupFilePath);
61
+ const setupFileSourcePath = (0, node_path_1.join)(this.extensionsSrcPath, setupFilePath);
95
62
  compilation.fileDependencies.add(setupFileSourcePath);
96
63
  emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
97
- compilation.emitAsset(node_path_1.default.join(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
64
+ compilation.emitAsset((0, node_path_1.join)(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
98
65
  return [parents.join("-") /* blockSlug */, setupFilePath];
99
66
  }));
100
67
  }
@@ -129,11 +96,12 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
129
96
  const isCss = (0, shared_1.isStyleField)(assetType);
130
97
  const handleGroup = isCss ? 'styleHandles'
131
98
  : ((0, shared_1.isScriptModuleField)(assetType) ? 'scriptModuleHandles' : 'scriptHandles');
99
+ const { dependencies, module_dependencies } = assetData;
132
100
  blockExtensionsConfig[handleGroup][handle] = {
133
101
  src: isCss ? assetPath.replace(/\.js$/, ".css") : assetPath,
134
102
  rest: isCss || key.startsWith("editor")
135
- ? [assetData.dependencies, assetData.version]
136
- : [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 }]
137
105
  };
138
106
  (blockExtensionsConfig.blocks[blockSlug] ?? (blockExtensionsConfig.blocks[blockSlug] = {}))[key] = handle;
139
107
  }
@@ -156,7 +124,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
156
124
  .toSorted(([a], [b]) => a.localeCompare(b)));
157
125
  (0, shared_1.emitPHPWriterAsAsset)(new php_writer_1.PHPWriter()
158
126
  .call("Plaudit\\Common\\Lib\\GutenbergUtils::loadExtensionsV3", [new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)(blockExtensionsConfig, false)), expressions_1.Op.concat(expressions_1.Constants.__DIR__, '/'),
159
- expressions_1.Expr.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__])]), compilation, node_path_1.default.join(this.dest.destination, "extensions-loader.php"));
127
+ expressions_1.Expr.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__])]), compilation, (0, node_path_1.join)(this.dest.destination, "extensions-loader.php"));
160
128
  }
161
129
  attachUniquePhase(compilation) {
162
130
  compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
@@ -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.6.3",
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.94.1",
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",
@@ -40,20 +40,20 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@plaudit/php-writer": "^1.4.1",
43
- "@plaudit/postcss-color-function": "^5.0.0",
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.44.0",
47
- "@wordpress/scripts": "^32.0.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.7",
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.12",
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",