@plaudit/webpack-extensions 2.85.0 → 2.85.3

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,18 @@ 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
+ ## [2.85.3] - 2026-03-06
9
+ ### Fixed
10
+ - `defer` and `async` not being supported strategies in some pipelines
11
+
12
+ ## [2.85.2] - 2026-03-06
13
+ ### Fixed
14
+ - Issues caused by trying to save a couple of cycles by using `hasAnyKeys` in place of checking the actual keys
15
+
16
+ ## [2.85.1] - 2026-03-06
17
+ ### Fixed
18
+ - Inlined scripts without any other path query parameters not being placed in the footer by default
19
+
8
20
  ## [2.85.0] - 2026-03-05
9
21
  ### Added
10
22
  - Support for inlining (and otherwise controlling the enqueuing of) assets
package/USER-GUIDE.md CHANGED
@@ -29,6 +29,7 @@
29
29
  * [Reference](#reference)
30
30
  * [Root Options](#root-options)
31
31
  * [Per-Entrypoint Options](#per-entrypoint-options)
32
+ * [Path Queries](#path-queries)
32
33
  * [Boolean-form](#boolean-form)
33
34
  * [String-form](#string-form)
34
35
  * [Object-form](#object-form)
@@ -269,7 +270,7 @@ After building, each asset gets a handle you can reference in PHP.
269
270
  **Best way:** Check the generated loader files after building:
270
271
  - `dist/blocks/blocks-loader.php`
271
272
  - `dist/extensions/extensions-loader.php`
272
- - The first argument of the `wp_register_script` and `wp_register_style` calls in `dist/plain-entrypoints-loader.php`
273
+ - The first argument of the `wp_register_script` and `wp_register_style` calls in `dist/plain-entrypoints-loader.php`
273
274
 
274
275
  ### Example: Manual Enqueue with Localization
275
276
 
@@ -468,7 +469,8 @@ src/blocks/
468
469
  #### Notes
469
470
  - Blocks **should** be created with `pnpm @plaudit/scaffold create block`
470
471
  - template.php and setup.php files are automatically loaded; however, they can be manually specified if desired
471
- - Script and Style files **must** be specified using the `file:./<path here>` syntax in the appropriate keys. See [WordPress' `block.json` reference](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/) for further details
472
+ - Script and Style files **must** be specified using the `file:./<path here>[?path-query-here]` syntax in the appropriate keys. See [WordPress' `block.json` reference](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/) for further details
473
+ - The `[?path-query-here]` component is something that we added. You can see more details in its section [here](#path-queries)
472
474
 
473
475
  #### Per-Entrypoint Options
474
476
  The `blocks` entrypoint type doesn't have any.
@@ -1,4 +1,4 @@
1
- import { Compilation } from "webpack";
1
+ import type { Compilation } from "webpack";
2
2
  import { InlinedAsset, PathQueryParameters, ScriptArgsObject, UsageLocations } from "../shared";
3
3
  export declare function getAssetFileContents(compilation: Compilation, name: string): string;
4
4
  export declare function unpackPotentiallyPrefixedFilePath(filePath: string): [string, PathQueryParameters | undefined];
@@ -40,8 +40,8 @@ export type NormalizedScriptEnqueuingControlFlags = {
40
40
  /**
41
41
  * This function does a few things:
42
42
  * <ol>
43
- * <li>It extracts strategy, in_footer, and fetchpriority from pathQueryParameters</li>
44
- * <li>If the strategy is, 'inline', it records the contents of the asset for later injection inline and removes the asset from the compilation output</li>
43
+ * <li>It extracts inline, position, strategy, in_footer, and fetchpriority from pathQueryParameters</li>
44
+ * <li>If inline is true or the strategy is, 'inline', it records the contents of the asset for later injection inline and removes the asset from the compilation output</li>
45
45
  * </ol>
46
46
  * @param compilation
47
47
  * @param file
@@ -13,8 +13,8 @@ exports.isValidPositionForInlineStrategy = isValidPositionForInlineStrategy;
13
13
  exports.newInvalidPositionForInlineStrategyError = newInvalidPositionForInlineStrategyError;
14
14
  exports.mergeInPathQueryParameters = mergeInPathQueryParameters;
15
15
  exports.parseScriptArgsObjectFromPathQueryParameters = parseScriptArgsObjectFromPathQueryParameters;
16
- const shared_1 = require("../shared");
17
16
  const node_path_1 = require("node:path");
17
+ const shared_1 = require("../shared");
18
18
  function getAssetFileContents(compilation, name) {
19
19
  const asset = compilation.getAsset(name);
20
20
  if (!asset) {
@@ -126,25 +126,24 @@ function unpackRegisterScriptArgsFromPathQueryParameters(pathQueryParameters, fi
126
126
  if (pathQueryParameters === undefined) {
127
127
  return undefined;
128
128
  }
129
- let hasAnyKeys = false;
130
129
  let baseArgs;
131
130
  const strategy = pathQueryParameters['strategy'];
132
131
  switch (strategy) {
132
+ case 'defer':
133
+ case 'async':
134
+ baseArgs = { strategy };
135
+ break;
133
136
  case 'eager':
134
- hasAnyKeys = true;
135
137
  baseArgs = { strategy: 'eager' };
136
138
  break;
137
139
  case 'lazy':
138
- hasAnyKeys = true;
139
140
  baseArgs = { strategy: 'defer', in_footer: true };
140
141
  break;
141
142
  case 'inline':
142
- hasAnyKeys = true;
143
143
  baseArgs = { inline: true };
144
144
  break;
145
145
  case true:
146
146
  case false:
147
- hasAnyKeys = true;
148
147
  baseArgs = { in_footer: strategy };
149
148
  break;
150
149
  case null:
@@ -162,7 +161,6 @@ function unpackRegisterScriptArgsFromPathQueryParameters(pathQueryParameters, fi
162
161
  if (!isValidInFooter(in_footer)) {
163
162
  throw newInvalidInFooterError(in_footer, file);
164
163
  }
165
- hasAnyKeys = true;
166
164
  baseArgs.in_footer = in_footer;
167
165
  }
168
166
  if (pathQueryParameters['fetchpriority'] !== undefined) {
@@ -172,18 +170,15 @@ function unpackRegisterScriptArgsFromPathQueryParameters(pathQueryParameters, fi
172
170
  if (baseArgs.fetchpriority !== undefined && baseArgs.fetchpriority !== pathQueryParameters['fetchpriority']) {
173
171
  throw (0, shared_1.newWebpackErrorForFile)(`The strategy and fetchpriority values in the ${sourceType} for the file conflict. Got ${strategy} and ${pathQueryParameters['fetchpriority']}`, file);
174
172
  }
175
- hasAnyKeys = true;
176
173
  baseArgs.fetchpriority = pathQueryParameters['fetchpriority'];
177
174
  }
178
- if (pathQueryParameters['inline'] !== undefined) {
179
- }
180
- return hasAnyKeys ? baseArgs : undefined;
175
+ return Object.keys(baseArgs).length > 0 ? baseArgs : undefined;
181
176
  }
182
177
  /**
183
178
  * This function does a few things:
184
179
  * <ol>
185
- * <li>It extracts strategy, in_footer, and fetchpriority from pathQueryParameters</li>
186
- * <li>If the strategy is, 'inline', it records the contents of the asset for later injection inline and removes the asset from the compilation output</li>
180
+ * <li>It extracts inline, position, strategy, in_footer, and fetchpriority from pathQueryParameters</li>
181
+ * <li>If inline is true or the strategy is, 'inline', it records the contents of the asset for later injection inline and removes the asset from the compilation output</li>
187
182
  * </ol>
188
183
  * @param compilation
189
184
  * @param file
@@ -195,20 +190,16 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
195
190
  }
196
191
  const scriptArgsObject = {};
197
192
  let inlinedAsset = undefined;
198
- let hasAnyKeys = false;
199
193
  const strategy = pathQueryParameters['strategy'];
200
194
  switch (strategy) {
201
195
  case 'async':
202
196
  case 'defer':
203
- hasAnyKeys = true;
204
197
  scriptArgsObject.strategy = strategy;
205
198
  break;
206
199
  case 'eager':
207
- hasAnyKeys = true;
208
200
  scriptArgsObject.in_footer = false;
209
201
  break;
210
202
  case 'lazy':
211
- hasAnyKeys = true;
212
203
  scriptArgsObject.strategy = 'defer';
213
204
  scriptArgsObject.in_footer = true;
214
205
  break;
@@ -221,7 +212,6 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
221
212
  break;
222
213
  case true:
223
214
  case false:
224
- hasAnyKeys = true;
225
215
  scriptArgsObject.in_footer = strategy;
226
216
  break;
227
217
  case null:
@@ -236,7 +226,6 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
236
226
  if (!isValidInFooter(in_footer)) {
237
227
  throw newInvalidInFooterError(in_footer, file);
238
228
  }
239
- hasAnyKeys = true;
240
229
  scriptArgsObject.in_footer = in_footer;
241
230
  }
242
231
  if (inlinedAsset === undefined && pathQueryParameters['inline']) {
@@ -265,10 +254,9 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
265
254
  if (inlinedAsset !== undefined) {
266
255
  compilation.warnings.push((0, shared_1.newWebpackErrorForFile)("Fetchpriority has no effect on inlined assets", file));
267
256
  }
268
- hasAnyKeys = true;
269
257
  scriptArgsObject.fetchpriority = fetchpriority;
270
258
  }
271
- return hasAnyKeys ? { scriptArgsObject, inlinedAsset } : { inlinedAsset };
259
+ return Object.keys(scriptArgsObject).length > 0 ? { scriptArgsObject, inlinedAsset } : { inlinedAsset };
272
260
  }
273
261
  function removeFileAndAssetPHP(compilation, file) {
274
262
  const pathParts = (0, node_path_1.parse)(file);
@@ -232,7 +232,7 @@ function buildVerifiedConfig(config) {
232
232
  }
233
233
  if (destination !== undefined) {
234
234
  const effectiveDestination = toEffectiveWebpackDestination(destination);
235
- allocatedDestinations[effectiveDestination] = rawSource[0]; // We need to pre-populate the allocatedDestinations map with statically-declared destinations
235
+ allocatedDestinations[effectiveDestination] = rawSource[0]; // We need to pre-populate the allocatedDestinations map with statically declared destinations
236
236
  return [rawSource[0], { ...normalizedParts, locations, destination, effectiveDestination, staticallyDeclaredDestination: true, pathQueryParameters }];
237
237
  }
238
238
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.85.0",
3
+ "version": "2.85.3",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@plaudit/gutenberg-api-extensions": "^2.87.0",
28
28
  "@types/browser-sync-webpack-plugin": "^2.2.5",
29
- "@types/node": "^25.3.4",
29
+ "@types/node": "^25.3.5",
30
30
  "@types/postcss-functions": "^4.0.4",
31
31
  "@types/tapable": "^2.3.0",
32
32
  "@types/webpack-sources": "^3.2.3",