@plaudit/webpack-extensions 2.89.1 → 2.90.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
@@ -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.90.0] - 2026-05-04
64
+ ### Added
65
+ - PNPM 11 compatibility
66
+
67
+ ## [2.89.2] - 2026-04-27
68
+ ### Fixed
69
+ - An `ENOENT` error when the `srcDir` does not map to an actual directory on disk
70
+ - It now matches the behavior of manually-declared sources and exits due to not having anything to build
71
+
63
72
  ## [2.89.1] - 2026-04-06
64
73
  ### Fixed
65
74
  - The emitter for the Extensions v1 format including an extra path element
@@ -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
  }
@@ -156,7 +123,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
156
123
  .toSorted(([a], [b]) => a.localeCompare(b)));
157
124
  (0, shared_1.emitPHPWriterAsAsset)(new php_writer_1.PHPWriter()
158
125
  .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"));
126
+ 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
127
  }
161
128
  attachUniquePhase(compilation) {
162
129
  compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
package/dist/shared.d.ts CHANGED
@@ -249,3 +249,10 @@ export declare function resolveLegacyBlockScriptsInFolder(folder: string): strin
249
249
  * @param file something that represents the file that is being inlined (this is purely for error-reporting purposes)
250
250
  */
251
251
  export declare function appendAddInlineAssetCall(compilation: Compilation, writer: PHPWriter, handle: string, type: 'script' | 'style' | 'script_module', inlinedAsset: InlinedAsset, handleData: HandleData, file: string): void;
252
+ export declare function synchronousDirIterator(dirPath: string): Generator<import("node:fs").Dirent<string>, void, unknown>;
253
+ /**
254
+ * A type-guarded version of `instanceof Error` for Node.js.
255
+ * @author Joseph JDBar Barron
256
+ * @link https://dev.to/jdbar
257
+ */
258
+ export declare function instanceOfNodeError<T extends new (...args: any) => Error>(value: unknown, errorType: T): value is InstanceType<T> & NodeJS.ErrnoException;
package/dist/shared.js CHANGED
@@ -49,9 +49,11 @@ exports.emitPHPWriterAsAsset = emitPHPWriterAsAsset;
49
49
  exports.dedent = dedent;
50
50
  exports.resolveLegacyBlockScriptsInFolder = resolveLegacyBlockScriptsInFolder;
51
51
  exports.appendAddInlineAssetCall = appendAddInlineAssetCall;
52
+ exports.synchronousDirIterator = synchronousDirIterator;
53
+ exports.instanceOfNodeError = instanceOfNodeError;
52
54
  const node_crypto_1 = require("node:crypto");
53
- const node_fs_1 = __importDefault(require("node:fs"));
54
- const promises_1 = __importDefault(require("node:fs/promises"));
55
+ const node_fs_1 = require("node:fs");
56
+ const promises_1 = require("node:fs/promises");
55
57
  const node_path_1 = __importDefault(require("node:path"));
56
58
  const php_writer_1 = require("@plaudit/php-writer");
57
59
  const expressions_1 = require("@plaudit/php-writer/expressions");
@@ -192,7 +194,7 @@ function kebabCase(value) {
192
194
  return kebabCaseRegexes.reduce((str, [pattern, replacement]) => str.replace(pattern, replacement), value).toLowerCase();
193
195
  }
194
196
  async function loadEnvFile(filePath) {
195
- return promises_1.default.readFile(filePath, 'utf-8').then(parseEnvFile, () => ({}));
197
+ return (0, promises_1.readFile)(filePath, 'utf-8').then(parseEnvFile, () => ({}));
196
198
  }
197
199
  function parseEnvFile(contents) {
198
200
  return Object.fromEntries(contents.split(/(\r?\n)+/).map(line => line.trim())
@@ -299,12 +301,12 @@ function dedent(text) {
299
301
  }
300
302
  function resolveLegacyBlockScriptsInFolder(folder) {
301
303
  const blockScriptEntrypoints = [];
302
- for (const blockDir of node_fs_1.default.readdirSync(folder)) {
304
+ for (const blockDir of (0, node_fs_1.readdirSync)(folder)) {
303
305
  const fullBlockDir = node_path_1.default.join(folder, blockDir);
304
306
  const packageJSON = node_path_1.default.join(fullBlockDir, 'package.json');
305
- if (node_fs_1.default.existsSync(packageJSON)) {
306
- const main = JSON.parse(node_fs_1.default.readFileSync(packageJSON, 'utf8'))['main'];
307
- if (main && node_fs_1.default.existsSync(node_path_1.default.join(fullBlockDir, main))) {
307
+ if ((0, node_fs_1.existsSync)(packageJSON)) {
308
+ const main = JSON.parse((0, node_fs_1.readFileSync)(packageJSON, 'utf8'))['main'];
309
+ if (main && (0, node_fs_1.existsSync)(node_path_1.default.join(fullBlockDir, main))) {
308
310
  blockScriptEntrypoints.push(node_path_1.default.join(fullBlockDir, main));
309
311
  }
310
312
  }
@@ -340,3 +342,24 @@ function appendAddInlineAssetCall(compilation, writer, handle, type, inlinedAsse
340
342
  }
341
343
  writer.call(`wp_add_inline_${type}`, args);
342
344
  }
345
+ function* synchronousDirIterator(dirPath) {
346
+ try {
347
+ using dir = (0, node_fs_1.opendirSync)(dirPath);
348
+ for (let dirent; (dirent = dir.readSync()) !== null;) {
349
+ yield dirent;
350
+ }
351
+ }
352
+ catch (e) {
353
+ if (!instanceOfNodeError(e, Error) || e.code !== 'ENOENT') {
354
+ throw e;
355
+ }
356
+ }
357
+ }
358
+ /**
359
+ * A type-guarded version of `instanceof Error` for Node.js.
360
+ * @author Joseph JDBar Barron
361
+ * @link https://dev.to/jdbar
362
+ */
363
+ function instanceOfNodeError(value, errorType) {
364
+ return !!value && value instanceof errorType;
365
+ }
@@ -1,4 +1,4 @@
1
- import type { AdvancedOutputConfig, PlauditWordpressWebpackConfig } from "../shared";
1
+ import { type AdvancedOutputConfig, type PlauditWordpressWebpackConfig } from "../shared";
2
2
  export declare const enum SourceType {
3
3
  blocks = "blocks",
4
4
  extensions = "extensions",
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSourceType = isSourceType;
4
4
  exports.resolveAllConfigLevelEntrypoints = resolveAllConfigLevelEntrypoints;
5
- const node_fs_1 = require("node:fs");
6
5
  const node_path_1 = require("node:path");
7
6
  const location_encoding_filename_parser_1 = require("./location-encoding-filename-parser");
8
7
  const path_query_and_related_helpers_1 = require("./path-query-and-related-helpers");
8
+ const shared_1 = require("../shared");
9
9
  function isSourceType(str) {
10
10
  return str === "blocks" /* SourceType.blocks */ || str === "extensions" /* SourceType.extensions */ || str === "plain" /* SourceType.plain */;
11
11
  }
@@ -38,8 +38,7 @@ function resolveAllConfigLevelEntrypoints(config, projectRoot = process.cwd()) {
38
38
  const dynamicallyIncludedEntrypoints = [];
39
39
  if (srcDir) { // This will only work if we have a unified src root
40
40
  const dynamicallyIncludedEntrypointsRoot = (0, node_path_1.isAbsolute)(srcDir) ? srcDir : (0, node_path_1.join)(projectRoot, srcDir);
41
- using dir = (0, node_fs_1.opendirSync)(dynamicallyIncludedEntrypointsRoot);
42
- for (let dirent; (dirent = dir.readSync()) !== null;) {
41
+ for (const dirent of (0, shared_1.synchronousDirIterator)(dynamicallyIncludedEntrypointsRoot)) {
43
42
  if (dirent.name in configSrc || `./${dirent.name}` in configSrc) {
44
43
  continue;
45
44
  }
@@ -49,8 +48,7 @@ function resolveAllConfigLevelEntrypoints(config, projectRoot = process.cwd()) {
49
48
  dynamicallyIncludedEntrypoints.push([dirent.name, { directoryLayout: dirent.name }]);
50
49
  continue;
51
50
  }
52
- using nestedDir = (0, node_fs_1.opendirSync)((0, node_path_1.join)(dynamicallyIncludedEntrypointsRoot, dirent.name));
53
- for (let nestedDirent; (nestedDirent = nestedDir.readSync()) !== null;) {
51
+ for (const nestedDirent of (0, shared_1.synchronousDirIterator)((0, node_path_1.join)(dynamicallyIncludedEntrypointsRoot, dirent.name))) {
54
52
  if (!nestedDirent.isFile()) {
55
53
  continue;
56
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.89.1",
3
+ "version": "2.90.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -28,34 +28,34 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@plaudit/gutenberg-api-extensions": "^2.90.1",
31
+ "@plaudit/gutenberg-api-extensions": "^2.97.0",
32
32
  "@types/browser-sync-webpack-plugin": "^2.2.5",
33
- "@types/node": "^25.5.2",
33
+ "@types/node": "^25.6.0",
34
34
  "@types/postcss-functions": "^4.0.4",
35
35
  "@types/tapable": "^2.3.0",
36
36
  "@types/webpack-sources": "^3.2.3",
37
37
  "postcss-load-config": "^4.0.2",
38
38
  "postcss-loader": "^7.3.4",
39
- "typescript": "^6.0.2",
39
+ "typescript": "^6.0.3",
40
40
  "webpack-bundle-analyzer": "^4.10.2"
41
41
  },
42
42
  "dependencies": {
43
43
  "@plaudit/php-writer": "^1.4.1",
44
- "@plaudit/postcss-color-function": "^5.0.0",
44
+ "@plaudit/postcss-color-function": "^5.1.0",
45
45
  "@plaudit/postcss-legacy-shorthand": "^1.0.0",
46
46
  "@plaudit/postcss-silent-extend": "^3.0.0",
47
47
  "@plaudit/postcss-strip-units": "^3.0.0",
48
48
  "@plaudit/postcss-variables": "^1.1.0",
49
- "@wordpress/dependency-extraction-webpack-plugin": "^6.43.0",
50
- "@wordpress/scripts": "^31.8.0",
51
- "autoprefixer": "^10.4.27",
49
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.45.0",
50
+ "@wordpress/scripts": "^32.1.0",
51
+ "autoprefixer": "^10.5.0",
52
52
  "browser-sync": "^3.0.4",
53
53
  "copy-webpack-plugin": "10.2.4",
54
54
  "css-minimizer-webpack-plugin": "^6.0.0",
55
55
  "fork-ts-checker-webpack-plugin": "^9.1.0",
56
56
  "http-proxy-middleware": "^3.0.5",
57
57
  "json2php": "^0.0.12",
58
- "postcss": "^8.5.8",
58
+ "postcss": "^8.5.13",
59
59
  "postcss-calc": "^9.0.1",
60
60
  "postcss-discard-comments": "^6.0.2",
61
61
  "postcss-functions": "^4.0.2",
@@ -67,7 +67,7 @@
67
67
  "postcss-reporter": "^7.1.0",
68
68
  "postcss-simple-vars": "^7.0.1",
69
69
  "postcss-url": "^10.1.3",
70
- "webpack": "^5.105.4",
70
+ "webpack": "^5.106.2",
71
71
  "webpack-remove-empty-scripts": "^1.1.1",
72
72
  "xml-formatter": "^3.7.0"
73
73
  },
@@ -75,6 +75,7 @@
75
75
  "node": ">=20"
76
76
  },
77
77
  "scripts": {
78
+ "pnpm:devPreinstall": "pnpm add --config '@plaudit/pnpm-plugin-plaudit-config'",
78
79
  "build": "tsc",
79
80
  "clean": "rm -rf dist",
80
81
  "build:clean": "pnpm run clean && pnpm run build",