@plaudit/webpack-extensions 3.1.0 → 3.1.1

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.1.1] - 2026-03-06
9
+ ### Fixed
10
+ - Inlined scripts without any other path query parameters not being placed in the footer by default
11
+ - This comes from version `2.85.2`
12
+
8
13
  ## [3.1.0] - 2026-03-05
9
14
  ### Added
10
15
  - Support for inlining (and otherwise controlling the enqueuing of) assets
@@ -31,6 +36,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
31
36
  - Legacy PostCSS features that have been integrated into modern CSS
32
37
  - `@extends` support
33
38
 
39
+ ## [2.85.2] - 2026-03-06
40
+ ### Fixed
41
+ - Issues caused by trying to save a couple of cycles by using `hasAnyKeys` in place of checking the actual keys
42
+
43
+ ## [2.85.1] - 2026-03-06
44
+ ### Fixed
45
+ - Inlined scripts without any other path query parameters not being placed in the footer by default
46
+
34
47
  ## [2.85.0] - 2026-03-05
35
48
  ### Added
36
49
  - 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,20 @@ 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) {
133
132
  case 'eager':
134
- hasAnyKeys = true;
135
133
  baseArgs = { strategy: 'eager' };
136
134
  break;
137
135
  case 'lazy':
138
- hasAnyKeys = true;
139
136
  baseArgs = { strategy: 'defer', in_footer: true };
140
137
  break;
141
138
  case 'inline':
142
- hasAnyKeys = true;
143
139
  baseArgs = { inline: true };
144
140
  break;
145
141
  case true:
146
142
  case false:
147
- hasAnyKeys = true;
148
143
  baseArgs = { in_footer: strategy };
149
144
  break;
150
145
  case null:
@@ -162,7 +157,6 @@ function unpackRegisterScriptArgsFromPathQueryParameters(pathQueryParameters, fi
162
157
  if (!isValidInFooter(in_footer)) {
163
158
  throw newInvalidInFooterError(in_footer, file);
164
159
  }
165
- hasAnyKeys = true;
166
160
  baseArgs.in_footer = in_footer;
167
161
  }
168
162
  if (pathQueryParameters['fetchpriority'] !== undefined) {
@@ -172,18 +166,15 @@ function unpackRegisterScriptArgsFromPathQueryParameters(pathQueryParameters, fi
172
166
  if (baseArgs.fetchpriority !== undefined && baseArgs.fetchpriority !== pathQueryParameters['fetchpriority']) {
173
167
  throw (0, shared_1.newWebpackErrorForFile)(`The strategy and fetchpriority values in the ${sourceType} for the file conflict. Got ${strategy} and ${pathQueryParameters['fetchpriority']}`, file);
174
168
  }
175
- hasAnyKeys = true;
176
169
  baseArgs.fetchpriority = pathQueryParameters['fetchpriority'];
177
170
  }
178
- if (pathQueryParameters['inline'] !== undefined) {
179
- }
180
- return hasAnyKeys ? baseArgs : undefined;
171
+ return Object.keys(baseArgs).length > 0 ? baseArgs : undefined;
181
172
  }
182
173
  /**
183
174
  * This function does a few things:
184
175
  * <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>
176
+ * <li>It extracts inline, position, strategy, in_footer, and fetchpriority from pathQueryParameters</li>
177
+ * <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
178
  * </ol>
188
179
  * @param compilation
189
180
  * @param file
@@ -195,20 +186,16 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
195
186
  }
196
187
  const scriptArgsObject = {};
197
188
  let inlinedAsset = undefined;
198
- let hasAnyKeys = false;
199
189
  const strategy = pathQueryParameters['strategy'];
200
190
  switch (strategy) {
201
191
  case 'async':
202
192
  case 'defer':
203
- hasAnyKeys = true;
204
193
  scriptArgsObject.strategy = strategy;
205
194
  break;
206
195
  case 'eager':
207
- hasAnyKeys = true;
208
196
  scriptArgsObject.in_footer = false;
209
197
  break;
210
198
  case 'lazy':
211
- hasAnyKeys = true;
212
199
  scriptArgsObject.strategy = 'defer';
213
200
  scriptArgsObject.in_footer = true;
214
201
  break;
@@ -221,7 +208,6 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
221
208
  break;
222
209
  case true:
223
210
  case false:
224
- hasAnyKeys = true;
225
211
  scriptArgsObject.in_footer = strategy;
226
212
  break;
227
213
  case null:
@@ -236,7 +222,6 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
236
222
  if (!isValidInFooter(in_footer)) {
237
223
  throw newInvalidInFooterError(in_footer, file);
238
224
  }
239
- hasAnyKeys = true;
240
225
  scriptArgsObject.in_footer = in_footer;
241
226
  }
242
227
  if (inlinedAsset === undefined && pathQueryParameters['inline']) {
@@ -265,10 +250,9 @@ function parseScriptArgsObjectFromPathQueryParameters(compilation, file, pathQue
265
250
  if (inlinedAsset !== undefined) {
266
251
  compilation.warnings.push((0, shared_1.newWebpackErrorForFile)("Fetchpriority has no effect on inlined assets", file));
267
252
  }
268
- hasAnyKeys = true;
269
253
  scriptArgsObject.fetchpriority = fetchpriority;
270
254
  }
271
- return hasAnyKeys ? { scriptArgsObject, inlinedAsset } : { inlinedAsset };
255
+ return Object.keys(scriptArgsObject).length > 0 ? { scriptArgsObject, inlinedAsset } : { inlinedAsset };
272
256
  }
273
257
  function removeFileAndAssetPHP(compilation, file) {
274
258
  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": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build",
@@ -45,7 +45,7 @@
45
45
  "browser-sync": "^3.0.4",
46
46
  "copy-webpack-plugin": "10.2.4",
47
47
  "css-minimizer-webpack-plugin": "^7.0.4",
48
- "cssnano": "^7.1.2",
48
+ "cssnano": "^7.1.3",
49
49
  "fork-ts-checker-webpack-plugin": "^9.1.0",
50
50
  "http-proxy-middleware": "^3.0.5",
51
51
  "json2php": "^0.0.12",