@plaudit/webpack-extensions 3.21.0 → 3.21.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,15 @@ 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.21.1] - 2026-09-04
9
+ ### Fixed
10
+ - The `inline` flag not getting picked up if it was set from within the webpack.config.js file
11
+ - Forward-port from `2.99.3`
12
+ - Inlined assets getting put in the registered assets list
13
+ - Forward-port from `2.99.3`
14
+ - An unnecessary call to `plaudit_webpack_extensions__resolve_base_uri` being emitted when a "registration" batch exclusively contains inlined assets
15
+ - Forward-port from `2.99.3`
16
+
8
17
  ## [3.21.0] - 2026-09-03
9
18
  ### Added
10
19
  - Logic to associate inline scripts with non-inlined scripts that have the same handle for Plain entrypoints
@@ -13,52 +22,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
22
  ## [3.20.2] - 2026-09-01
14
23
  ### Removed
15
24
  - The duplicated `isDistDevOutputPath` logic around the initialization of the `@plaudit/dev-webpack-plugin`
16
- - This comes from version `2.99.2`
25
+ - Forward-port from `2.99.2`
17
26
 
18
27
  ## [3.20.1] - 2026-08-26
19
28
  ### Internals
20
29
  - Updated to the 34.x line of `@wordpress/scripts`
21
- - This comes from version `2.99.1`
30
+ - Forward-port from `2.99.1`
22
31
  - Removed the `@types/wordpress` override
23
- - This comes from version `2.99.1`
32
+ - Forward-port from `2.99.1`
24
33
 
25
34
  ## [3.20.0] - 2026-08-24
26
35
  ### Added
27
36
  - Mixable versions of the `BiPhasicGroup...` plugins
28
- - This comes from version `2.99.0`
37
+ - Forward-port from `2.99.0`
29
38
  - Entrypoints to allow other code to reference some of the plugins and utilities
30
- - This comes from version `2.99.0`
39
+ - Forward-port from `2.99.0`
31
40
 
32
41
  ### Internals
33
42
  - Dropped unnecessary constructor parameters to make re-using the more general components easier
34
- - This comes from version `2.99.0`
43
+ - Forward-port from `2.99.0`
35
44
 
36
45
  ## [3.19.0] - 2026-08-18
37
46
  ### Added
38
47
  - Automatic sync of WordPress's bundled packages list
39
- - This comes from version `2.98.0`
48
+ - Forward-port from `2.98.0`
40
49
 
41
50
  ## [3.18.0] - 2026-08-18
42
51
  ### Added
43
52
  - David's improvements to build pipeline efficiency (Credit: David)
44
- - This comes from version `2.97.0`
53
+ - Forward-port from `2.97.0`
45
54
  - Support for David's `@plaudit/dev-webpack-plugin` (Credit: David)
46
- - This comes from version `2.97.0`
55
+ - Forward-port from `2.97.0`
47
56
 
48
57
  ### Changed
49
58
  - To Webpack's standard plugin interface (`WebpackPluginInstance`)
50
- - This comes from version `2.97.0`
59
+ - Forward-port from `2.97.0`
51
60
 
52
61
  ### Removed
53
62
  - Browsersync and its tests (Credit: David)
54
- - This comes from version `2.97.0`
63
+ - Forward-port from `2.97.0`
55
64
 
56
65
  ## [3.17.0] - 2026-08-18
57
66
  ### Added
58
67
  - A port of WordPress's Dependency Extraction Webpack Plugin because they keep breaking it
59
- - This comes from version `2.96.0`
68
+ - Forward-port from `2.96.0`
60
69
  - Warnings and additional info for entrypoints that are lazy-loaded and assigned to actual locations
61
- - This comes from version `2.96.0`
70
+ - Forward-port from `2.96.0`
62
71
  - An `externalize` that is not a string, an array, an object, or false is now rejected rather than silently ignored
63
72
  - This matches with what webpack's `output.library` config supports
64
73
 
@@ -78,7 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
78
87
 
79
88
  ### Removed
80
89
  - `processTranslationConfigs` because it should not be used and didn't actually do anything
81
- - This comes from version `2.96.2`
90
+ - Forward-port from `2.96.2`
82
91
 
83
92
  ### Internals
84
93
  - Added more integration tests
@@ -87,9 +96,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
87
96
  ### Added
88
97
  - Logic so that files and directories with names equal to "example" or "examples" or that include "example" as a name segment are skipped
89
98
  - This is done to allow us to include example files
90
- - This comes from version `2.95.0`
99
+ - Forward-port from `2.95.0`
91
100
  - Updated the user guide with this information
92
- - This comes from version `2.95.0`
101
+ - Forward-port from `2.95.0`
93
102
 
94
103
  ### Fixed
95
104
  - The TOC in the user guide being out of date
@@ -97,25 +106,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
97
106
  ## [3.15.1] - 2026-07-20
98
107
  ### Fixed
99
108
  - A bug that caused all styles bound for editor use to be emitted as inline CSS
100
- - This comes from version `2.94.1`
109
+ - Forward-port from `2.94.1`
101
110
 
102
111
  ## [3.15.0] - 2026-07-17
103
112
  ### Changed
104
113
  - The `add_editor_style()` enqueue path to use `block_editor_settings_all` to avoid a litany of bugs courtesy of WordPress's high-quality code
105
- - This comes from version `2.94.0`
114
+ - Forward-port from `2.94.0`
106
115
 
107
116
  ## [3.14.1] - 2026-07-15
108
117
  ### Fixed
109
118
  - The new supported features code overriding unintended data in theme.json
110
- - This comes from version `2.93.1`
119
+ - Forward-port from `2.93.1`
111
120
 
112
121
  ## [3.14.0] - 2026-07-15
113
122
  ### Added
114
123
  - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
115
124
  - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
116
- - This comes from version `2.93.0`
125
+ - Forward-port from `2.93.0`
117
126
  - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
118
- - This comes from version `2.93.0`
127
+ - Forward-port from `2.93.0`
119
128
 
120
129
  ## [3.13.0] - 2026-07-14
121
130
  ### Added
@@ -167,45 +176,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
167
176
  ## [3.9.4] - 2026-06-10
168
177
  ### Fixed
169
178
  - Libraries externalizing in a way that does not account for the variable potentially being undeclared
170
- - This comes from version `2.92.4`
179
+ - Forward-port from `2.92.4`
171
180
 
172
181
  ## [3.9.3] - 2026-05-27
173
182
  ### Fixed
174
183
  - A couple more dependency snarls
175
- - This comes from version `2.92.3`
184
+ - Forward-port from `2.92.3`
176
185
 
177
186
  ## [3.9.2] - 2026-05-26
178
187
  ### Fixed
179
188
  - The `"supports-bindings": true` flag resulting in emission of invalid PHP code
180
- - This comes from version `2.92.2`
189
+ - Forward-port from `2.92.2`
181
190
 
182
191
  ## [3.9.1] - 2026-05-21
183
192
  ### Fixed
184
193
  - Compatibility issues with module-mode building
185
- - This comes from version `2.92.1`
194
+ - Forward-port from `2.92.1`
186
195
  - `module_dependencies` being set to `null` instead of being omitted
187
- - This comes from version `2.92.1`
196
+ - Forward-port from `2.92.1`
188
197
 
189
198
  ## [3.9.0] - 2026-05-20
190
199
  ### Added
191
200
  - Support for marking `block.json` attributes with `"supports-bindings": true` to enable block binding support in the editor
192
- - This comes from version `2.92.0`
201
+ - Forward-port from `2.92.0`
193
202
 
194
203
  ## [3.8.0] - 2026-05-20
195
204
  ### Added
196
205
  - Support for the `module_dependencies` property on `script` assets
197
- - This comes from version `2.91.0`
206
+ - Forward-port from `2.91.0`
198
207
 
199
208
  ## [3.7.0] - 2026-05-04
200
209
  ### Added
201
210
  - PNPM 11 compatibility
202
- - This comes from version `2.90.0`
211
+ - Forward-port from `2.90.0`
203
212
 
204
213
  ## [3.6.3] - 2026-04-27
205
214
  ### Fixed
206
215
  - An `ENOENT` error when the `srcDir` does not map to an actual directory on disk
207
216
  - It now matches the behavior of manually-declared sources and exits due to not having anything to build
208
- - This comes from version `2.89.2`
217
+ - Forward-port from `2.89.2`
209
218
 
210
219
  ## [3.6.2] - 2026-04-09
211
220
  ### Changed
@@ -214,44 +223,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
214
223
  ## [3.6.1] - 2026-04-06
215
224
  ### Fixed
216
225
  - The emitter for the Extensions v1 format including an extra path element
217
- - This comes from version `2.89.1`
226
+ - Forward-port from `2.89.1`
218
227
 
219
228
  ## [3.6.0] - 2026-03-31
220
229
  ### Changed
221
230
  - The block.json handling logic to use encoded location data in filenames that are enumerated within block.json
222
- - This comes from version `2.89.0`
231
+ - Forward-port from `2.89.0`
223
232
  - Inline scripts to not emit with a sourcemap outside of dev mode
224
- - This comes from version `2.89.0`
233
+ - Forward-port from `2.89.0`
225
234
 
226
235
  ### Fixed
227
236
  - Unnecessary `.asset.php` files being emitted for inlined scripts
228
- - This comes from version `2.89.0`
237
+ - Forward-port from `2.89.0`
229
238
 
230
239
  ## [3.5.2] - 2026-03-30
231
240
  ### Fixed
232
241
  - The conflicting handle detection logic in block.json handling
233
- - This comes from version `2.88.2`
242
+ - Forward-port from `2.88.2`
234
243
 
235
244
  ## [3.5.1] - 2026-03-30
236
245
  ### Fixed
237
246
  - The paths in package.json that were broken after switching to dist
238
- - This comes from version `2.88.1`
247
+ - Forward-port from `2.88.1`
239
248
 
240
249
  ## [3.5.0] - 2026-03-30
241
250
  ### Added
242
251
  - Support for explicitly setting the handle for block assets
243
- - This comes from version `2.88.0`
252
+ - Forward-port from `2.88.0`
244
253
 
245
254
  ## [3.4.1] - 2026-03-17
246
255
  ### Changed
247
256
  - The `blockdir-loader.php` generation logic to use static wp_register_* calls like `plain-entrypoints-loader.php`
248
- - This comes from version `2.87.1`
257
+ - Forward-port from `2.87.1`
249
258
 
250
259
  ## [3.4.0] - 2026-03-16
251
260
  ### Added
252
261
  - Support for a directory-based `extensions` layout
253
262
  - This only applies to sites using extensions v2 and higher
254
- - This comes from version `2.87.0`
263
+ - Forward-port from `2.87.0`
255
264
 
256
265
  ## [3.3.0] - 2026-03-16
257
266
  ### Added
@@ -268,25 +277,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
268
277
  ## [3.2.0] - 2026-03-16
269
278
  ### Added
270
279
  - Support for `Location-Encoding Filenames`
271
- - This comes from version `2.86.0`
280
+ - Forward-port from `2.86.0`
272
281
  - Support for standardized flag sets
273
- - This comes from version `2.86.0`
282
+ - Forward-port from `2.86.0`
274
283
 
275
284
  ## [3.1.2] - 2026-03-06
276
285
  ### Fixed
277
286
  - `defer` and `async` not being supported strategies in some pipelines
278
- - This comes from version `2.85.3`
287
+ - Forward-port from `2.85.3`
279
288
 
280
289
  ## [3.1.1] - 2026-03-06
281
290
  ### Fixed
282
291
  - Inlined scripts without any other path query parameters not being placed in the footer by default
283
- - This comes from version `2.85.2`
292
+ - Forward-port from `2.85.2`
284
293
 
285
294
  ## [3.1.0] - 2026-03-05
286
295
  ### Added
287
296
  - Support for inlining (and otherwise controlling the enqueuing of) assets
288
297
  - This only applies to plain entrypoints and assets declared within block.json files at present
289
- - This comes from version `2.85.0`
298
+ - Forward-port from `2.85.0`
290
299
 
291
300
  ## [3.0.1] - 2026-02-12
292
301
  ### Added
@@ -308,6 +317,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
308
317
  - Legacy PostCSS features that have been integrated into modern CSS
309
318
  - `@extends` support
310
319
 
320
+ ## [2.99.3] - 2026-09-04
321
+ ### Fixed
322
+ - The `inline` flag not getting picked up if it was set from within the webpack.config.js file
323
+ - Inlined assets getting put in the registered assets list
324
+ - An unnecessary call to `plaudit_webpack_extensions__resolve_base_uri` being emitted when a "registration" batch exclusively contains inlined assets
325
+
326
+ ### Internals
327
+ - Tweaked a few things to make adding new enqueue locations easier
328
+
311
329
  ## [2.99.2] - 2026-09-01
312
330
  ### Removed
313
331
  - The duplicated `isDistDevOutputPath` logic around the initialization of the `@plaudit/dev-webpack-plugin`
@@ -46,35 +46,29 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
46
46
  }
47
47
  const file = new php_writer_1.PHPFile();
48
48
  const writer = file.getWriter("");
49
- if (handleLists.register.length > 0) {
50
- if (!this.useUnifiedLoader) {
49
+ const hasRegisterScripts = handleLists.register.length > 0;
50
+ if (hasRegisterScripts || handleLists.inline.length > 0) {
51
+ if (hasRegisterScripts && !this.useUnifiedLoader) {
51
52
  (0, shared_1.emitResolveBaseUriFunction)(writer);
52
53
  }
53
54
  const baseUriVar = new expressions_1.Var("base_uri");
54
- for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleLists.register)) {
55
+ const inlineAndRegisterHandleLists = [...handleLists.register, ...handleLists.inline];
56
+ for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(inlineAndRegisterHandleLists)) {
55
57
  writer.action("init", writer => {
56
- writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
58
+ const state = { baseUriVar, emitDir, writer };
59
+ if (prioritizedHandleList.find(handleItem => handleItem.data.inlinedAsset === undefined)) {
60
+ writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
61
+ }
57
62
  for (const handleItem of prioritizedHandleList) {
58
- PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, handleItem, { baseUriVar, emitDir, writer });
63
+ PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, handleItem, state);
59
64
  if (handleItem.data.associatedInlinedHandles !== undefined) {
60
65
  for (const associatedHandle of handleItem.data.associatedInlinedHandles) {
61
- PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, { data: associatedHandle, handle: handleItem.handle, type: associatedHandle.type }, { baseUriVar, emitDir, writer });
66
+ PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, { data: associatedHandle, handle: handleItem.handle, type: associatedHandle.type }, state);
62
67
  }
63
68
  }
64
69
  }
65
70
  }, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
66
71
  }
67
- for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleLists.inline)) {
68
- writer.action("init", writer => {
69
- writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
70
- for (const { handle, type, data } of prioritizedHandleList) {
71
- writer.call(`wp_register_${type}`, [handle, false, ...data.rest]);
72
- if (data.inlinedAsset !== undefined) {
73
- (0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, data);
74
- }
75
- }
76
- }, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
77
- }
78
72
  }
79
73
  PlainEntrypointsConfigFileGeneratorPlugin.appendEnqueuingHandleLists(writer, handleLists);
80
74
  const sortedEditorStyleHandles = sortedStyleHandles
@@ -196,12 +190,12 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
196
190
  static addHandlesToHandleLists(compilation, type, handles, handleLists) {
197
191
  const defaultPriority = 10;
198
192
  for (const [handle, data] of handles) {
199
- if (data.locations.register !== false) {
200
- handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
201
- }
202
- else if (data.inlinedAsset !== undefined) {
193
+ if (data.inlinedAsset !== undefined) {
203
194
  handleLists.inline.push({ handle, type, data, priority: typeof data.locations.inline === 'number' ? data.locations.inline : 10 });
204
195
  }
196
+ else if (data.locations.register !== false) {
197
+ handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
198
+ }
205
199
  if (data.lazyLoader !== undefined) {
206
200
  // A lazily loaded handle is enqueued by its generated function and never by an action, so it
207
201
  // is deliberately kept out of the location lists. Those lists are also what the lazy function
@@ -258,7 +252,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
258
252
  }
259
253
  }
260
254
  static appendEnqueuingHandleLists(writer, handleLists) {
261
- for (const [sln, { action, supports_hook_name, additional_action_code }] of (0, shared_1.constantEntries)(shared_1.standardLocationNamesMeta)) {
255
+ for (const [sln, { action, supports_hook_name, additional_action_code }] of (0, shared_1.iterableStandardLocationNamesMeta)()) {
262
256
  const handleList = handleLists[sln];
263
257
  if (handleList.length > 0) {
264
258
  writer.linebreak();
@@ -269,7 +263,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
269
263
  const hook_name_var = new expressions_1.Var("hook_name", "?string");
270
264
  writer.action(action, writer => {
271
265
  additional_action_code?.before?.(writer);
272
- if (hookNamedHandleLists.global) {
266
+ if (hookNamedHandleLists.global.length > 0) {
273
267
  for (const handle of hookNamedHandleLists.global) {
274
268
  writer.call(`wp_enqueue_${handle.type}`, [handle.handle]);
275
269
  }
@@ -370,7 +364,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
370
364
  const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
371
365
  const { lazyLoader, locations } = this.dest;
372
366
  const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
373
- const { assetMeta, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags), type === 'style' && (!!locations.clientEditor || locations.clientEditor === 0));
367
+ const { assetMeta, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags, this.dest.locations.inline !== undefined ? { inline: true } : undefined), type === 'style' && (!!locations.clientEditor || locations.clientEditor === 0));
374
368
  const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
375
369
  const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
376
370
  const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
package/dist/shared.d.ts CHANGED
@@ -42,15 +42,26 @@ export type HandleData = BaseHandleData & (AssetMetaSegment | {
42
42
  inlinedAsset?: undefined;
43
43
  assetContents?: string;
44
44
  });
45
+ type OptionalLocationMeta = {
46
+ supports_hook_name?: boolean;
47
+ additional_action_code?: {
48
+ before?(writer: PHPWriter): unknown;
49
+ after?(writer: PHPWriter): unknown;
50
+ };
51
+ alternate_names?: [string, ...string[]];
52
+ };
45
53
  export declare const standardLocationNamesMeta: {
46
54
  readonly clientView: {
47
55
  readonly action: "wp_enqueue_scripts";
56
+ readonly alternate_names: ["client-view", "view"];
48
57
  };
49
58
  readonly clientEditor: {
50
59
  readonly action: "enqueue_block_editor_assets";
60
+ readonly alternate_names: ["client-editor", "editor"];
51
61
  };
52
62
  readonly blockAssets: {
53
63
  readonly action: "enqueue_block_assets";
64
+ readonly alternate_names: ["block-assets"];
54
65
  };
55
66
  readonly admin: {
56
67
  readonly action: "admin_enqueue_scripts";
@@ -68,14 +79,11 @@ export declare const standardLocationNamesMeta: {
68
79
  };
69
80
  export type StandardLocationNameMeta = {
70
81
  action: typeof standardLocationNamesMeta[keyof typeof standardLocationNamesMeta]['action'];
71
- supports_hook_name?: boolean;
72
- additional_action_code?: {
73
- before?(writer: PHPWriter): unknown;
74
- after?(writer: PHPWriter): unknown;
75
- };
76
- };
82
+ } & OptionalLocationMeta;
77
83
  export type StandardLocationNames = keyof typeof standardLocationNamesMeta;
78
84
  export declare function isStandardLocationName(name: string): name is StandardLocationNames;
85
+ export declare function iterableStandardLocationNamesMeta(): [StandardLocationNames, StandardLocationNameMeta][];
86
+ export declare function normalizeLocationName(name: string): StandardLocationNames | 'register';
79
87
  type LocationWithHookNameSupport = boolean | number | string | string[] | {
80
88
  hook_name?: string | string[];
81
89
  priority?: number;
package/dist/shared.js CHANGED
@@ -20,6 +20,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.standardLocationNamesMeta = void 0;
21
21
  exports.isParsedAssetsJson = isParsedAssetsJson;
22
22
  exports.isStandardLocationName = isStandardLocationName;
23
+ exports.iterableStandardLocationNamesMeta = iterableStandardLocationNamesMeta;
24
+ exports.normalizeLocationName = normalizeLocationName;
23
25
  exports.isRegisterScriptArgsShorthandName = isRegisterScriptArgsShorthandName;
24
26
  exports.isNormalizedUsageLocations = isNormalizedUsageLocations;
25
27
  exports.convertHookLocationToNamesAndPriority = convertHookLocationToNamesAndPriority;
@@ -79,9 +81,9 @@ function isParsedAssetsJson(thing) {
79
81
  return true;
80
82
  }
81
83
  exports.standardLocationNamesMeta = {
82
- clientView: { action: "wp_enqueue_scripts" },
83
- clientEditor: { action: "enqueue_block_editor_assets" },
84
- blockAssets: { action: "enqueue_block_assets" },
84
+ clientView: { action: "wp_enqueue_scripts", alternate_names: ['client-view', 'view'] },
85
+ clientEditor: { action: "enqueue_block_editor_assets", alternate_names: ['client-editor', 'editor'] },
86
+ blockAssets: { action: "enqueue_block_assets", alternate_names: ['block-assets'] },
85
87
  admin: { action: "admin_enqueue_scripts", supports_hook_name: true },
86
88
  login: { action: "login_enqueue_scripts" },
87
89
  customizer: { action: "customize_controls_enqueue_scripts" },
@@ -90,6 +92,20 @@ exports.standardLocationNamesMeta = {
90
92
  function isStandardLocationName(name) {
91
93
  return Object.hasOwn(exports.standardLocationNamesMeta, name);
92
94
  }
95
+ function iterableStandardLocationNamesMeta() {
96
+ return constantEntries(exports.standardLocationNamesMeta);
97
+ }
98
+ function normalizeLocationName(name) {
99
+ if (isStandardLocationName(name) || name === 'register') {
100
+ return name;
101
+ }
102
+ for (const [standardName, { alternate_names }] of iterableStandardLocationNamesMeta()) {
103
+ if (alternate_names?.includes(name)) {
104
+ return standardName;
105
+ }
106
+ }
107
+ throw new Error(`"${name}" is neither a standard nor alternate location name`);
108
+ }
93
109
  function isRegisterScriptArgsShorthandName(name) {
94
110
  return ['lazy', 'eager', 'inline'].includes(name);
95
111
  }
@@ -17,14 +17,14 @@ export declare function parseLocationEncodingFilenameForBlock(filename: string,
17
17
  handle: ParsedLocationEncodingFilename['locations']['handle'];
18
18
  }) | undefined;
19
19
  /**
20
- * This handles detecting all keys of standardLocationNamesMeta as well as "view", "client-view", "editor", "client-editor", and "block-assets".
20
+ * This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
21
21
  * It MUST be kept in sync with standardLocationNamesMeta
22
22
  * @param segment
23
23
  */
24
24
  export declare function extractLocationFromPropertyEncodingFilenameSegment(segment: string): {
25
+ readonly locationName: false;
26
+ readonly priority?: undefined;
27
+ } | {
25
28
  readonly locationName: "admin" | "analytics" | "blockAssets" | "clientEditor" | "clientView" | "customizer" | "login" | "register";
26
29
  readonly priority: number | true;
27
- } | {
28
- readonly priority?: undefined;
29
- readonly locationName: false;
30
30
  };
@@ -98,27 +98,23 @@ function parseLocationEncodingFilenameForBlock(filename, errorBuilder = shared_1
98
98
  }
99
99
  return parsedFilename;
100
100
  }
101
- const standardLocationNamesAndPriorityPatternInFilenameSegment = /^(?:(?<view>clientView|client-view|view)|(?<editor>clientEditor|client-editor|editor)|(?<blockAssets>blockAssets|block-assets)|(?<locationName>admin|login|customizer|analytics|register))(?:[-=](?<priority>-?\d+))?$/;
101
+ let standardLocationNamesAndPriorityPatternInFilenameSegment;
102
102
  /**
103
- * This handles detecting all keys of standardLocationNamesMeta as well as "view", "client-view", "editor", "client-editor", and "block-assets".
103
+ * This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
104
104
  * It MUST be kept in sync with standardLocationNamesMeta
105
105
  * @param segment
106
106
  */
107
107
  function extractLocationFromPropertyEncodingFilenameSegment(segment) {
108
- const { view, editor, blockAssets, locationName, priority: rawPriority } = standardLocationNamesAndPriorityPatternInFilenameSegment.exec(segment)
109
- ?.groups ?? {};
110
- const priority = rawPriority !== undefined ? parseInt(rawPriority) : true;
111
- if (view) {
112
- return { locationName: "clientView", priority };
113
- }
114
- if (editor) {
115
- return { locationName: "clientEditor", priority };
108
+ if (!standardLocationNamesAndPriorityPatternInFilenameSegment) {
109
+ const matchableLocationNames = (0, shared_1.iterableStandardLocationNamesMeta)()
110
+ .flatMap(([standardName, { alternate_names = [] }]) => [standardName, ...alternate_names])
111
+ .join("|");
112
+ standardLocationNamesAndPriorityPatternInFilenameSegment = new RegExp(`^(?<locationName>${matchableLocationNames}|register)(?:[-=](?<priority>-?\\d+))?$`);
116
113
  }
117
- if (blockAssets) {
118
- return { locationName: "blockAssets", priority };
114
+ const { locationName, priority: rawPriority } = standardLocationNamesAndPriorityPatternInFilenameSegment.exec(segment)?.groups ?? {};
115
+ if (!locationName) {
116
+ return { locationName: false };
119
117
  }
120
- if (locationName) {
121
- return { locationName, priority };
122
- }
123
- return { locationName: false };
118
+ const priority = rawPriority !== undefined ? parseInt(rawPriority) : true;
119
+ return { locationName: (0, shared_1.normalizeLocationName)(locationName), priority };
124
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "3.21.0",
3
+ "version": "3.21.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,19 +34,19 @@
34
34
  }
35
35
  },
36
36
  "devDependencies": {
37
- "@plaudit/dev-webpack-plugin": "^1.3.1",
37
+ "@plaudit/dev-webpack-plugin": "^1.5.0",
38
38
  "@plaudit/gutenberg-api-extensions": "^2.98.2",
39
39
  "@types/jsdom": "^30.0.0",
40
- "@types/node": "^26.3.0",
40
+ "@types/node": "^26.4.1",
41
41
  "@types/postcss-functions": "^4.0.4",
42
42
  "@types/postcss-import": "^14.0.3",
43
43
  "@types/tapable": "^2.3.0",
44
44
  "@types/webpack-sources": "^3.2.3",
45
- "@wordpress/dependency-extraction-webpack-plugin": "^6.53.0",
45
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.54.0",
46
46
  "atob": "^2.1.2",
47
47
  "css-loader": "^6.11.0",
48
48
  "glob": "^7.2.3",
49
- "jest": "^30.4.2",
49
+ "jest": "^30.5.1",
50
50
  "lodash": "^4.18.1",
51
51
  "mini-css-extract-plugin": "^2.10.2",
52
52
  "mkdirp": "^3.0.1",
@@ -61,7 +61,7 @@
61
61
  "@plaudit/postcss-color-function": "^5.1.0",
62
62
  "@plaudit/postcss-strip-units": "^3.0.0",
63
63
  "@plaudit/postcss-variables": "^2.0.1",
64
- "@wordpress/scripts": "^34.1.0",
64
+ "@wordpress/scripts": "^34.2.0",
65
65
  "autoprefixer": "^10.5.4",
66
66
  "copy-webpack-plugin": "10.2.4",
67
67
  "css-minimizer-webpack-plugin": "^8.0.0",
@@ -69,7 +69,7 @@
69
69
  "fork-ts-checker-webpack-plugin": "^9.1.0",
70
70
  "jsdom": "^30.0.1",
71
71
  "json2php": "0.0.12",
72
- "postcss": "^8.5.26",
72
+ "postcss": "^8.5.28",
73
73
  "postcss-calc": "^10.1.1",
74
74
  "postcss-functions": "^4.0.2",
75
75
  "postcss-import": "^16.2.0",
@@ -79,7 +79,7 @@
79
79
  "postcss-property-lookup": "^3.0.0",
80
80
  "postcss-reporter": "^7.1.0",
81
81
  "postcss-url": "^10.1.4",
82
- "webpack": "^5.109.2",
82
+ "webpack": "^5.110.3",
83
83
  "webpack-remove-empty-scripts": "^1.1.1",
84
84
  "xml-formatter": "^3.7.0"
85
85
  },