@plaudit/webpack-extensions 2.89.1 → 2.89.2

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,11 @@ 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.89.2] - 2026-04-27
64
+ ### Fixed
65
+ - An `ENOENT` error when the `srcDir` does not map to an actual directory on disk
66
+ - It now matches the behavior of manually-declared sources and exits due to not having anything to build
67
+
63
68
  ## [2.89.1] - 2026-04-06
64
69
  ### Fixed
65
70
  - The emitter for the Extensions v1 format including an extra path element
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.89.2",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -28,15 +28,15 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@plaudit/gutenberg-api-extensions": "^2.90.1",
31
+ "@plaudit/gutenberg-api-extensions": "^2.94.1",
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": {
@@ -46,16 +46,16 @@
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.44.0",
50
+ "@wordpress/scripts": "^32.0.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.12",
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
  },