@plaudit/webpack-extensions 3.5.2 → 3.6.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,22 @@ 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.6.1] - 2026-04-06
9
+ ### Fixed
10
+ - The emitter for the Extensions v1 format including an extra path element
11
+ - This comes from version `2.89.1`
12
+
13
+ ## [3.6.0] - 2026-03-31
14
+ ### Changed
15
+ - The block.json handling logic to use encoded location data in filenames that are enumerated within block.json
16
+ - This comes from version `2.89.0`
17
+ - Inline scripts to not emit with a sourcemap outside of dev mode
18
+ - This comes from version `2.89.0`
19
+
20
+ ### Fixed
21
+ - Unnecessary `.asset.php` files being emitted for inlined scripts
22
+ - This comes from version `2.89.0`
23
+
8
24
  ## [3.5.2] - 2026-03-30
9
25
  ### Fixed
10
26
  - The conflicting handle detection logic in block.json handling
@@ -86,6 +102,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
86
102
  - Legacy PostCSS features that have been integrated into modern CSS
87
103
  - `@extends` support
88
104
 
105
+ ## [2.89.1] - 2026-04-06
106
+ ### Fixed
107
+ - The emitter for the Extensions v1 format including an extra path element
108
+
109
+ ## [2.89.0] - 2026-03-31
110
+ ### Changed
111
+ - The block.json handling logic to use encoded location data in filenames that are enumerated within block.json
112
+ - Inline scripts to not emit with a sourcemap outside of dev mode
113
+
114
+ ### Fixed
115
+ - Unnecessary `.asset.php` files being emitted for inlined scripts
116
+
89
117
  ## [2.88.2] - 2026-03-30
90
118
  ### Fixed
91
119
  - The conflicting handle detection logic in block.json handling
package/USER-GUIDE.md CHANGED
@@ -345,9 +345,9 @@ While every common flag is accounted for in this schema, there are some things t
345
345
  Location-encoding filenames are composed of two or more `.`-separated segments (the file extension being one of those segments).
346
346
  The following is a brief list of notes followed by a breakdown of the individual segments:
347
347
  - The only required segments are the location and type segments (the type segment is the file extension).
348
- - So long as there is at least one location and type segment (the type segment MUST be last), "invalid" segments are allowed (this is for the purposes of giving human-readable names to files)
349
- - Each file can enumerate any combination enqueuing locations
350
- - The first item is special in that, if it encodes a location, in can optionally be suffixed with a type override (see the [Enqueuing Location](#enqueuing-location) section for more details)
348
+ - So long as there is at least one location and type segment (the type segment MUST be last), "invalid" segments are allowed so that files can be given human-readable names
349
+ - Each file can list any combination enqueuing locations
350
+ - The first item is special in that, if it encodes a location, it can optionally be suffixed with a type override (see the [Enqueuing Location](#enqueuing-location) section for more details)
351
351
 
352
352
  Notes on how to read the following table:
353
353
  - Brackets in the token column mean "optional section"
@@ -472,7 +472,7 @@ If you use both methods for the same entrypoint, the dependencies from the confi
472
472
  ## Entrypoint Types
473
473
 
474
474
  ### Blocks
475
- This was first entrypoint type added, and, due to how it integrates with WordPress, it both has and needs the least amount of configuration.
475
+ This was the first entrypoint type added, and, due to how it integrates with WordPress, it both has and needs the least amount of configuration.
476
476
  In fact, under most circumstances, the proper configuration value is just `true`.
477
477
 
478
478
  #### File Structure
@@ -25,8 +25,10 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
25
25
  async processAssets(compilation, parsedAssetJsonProvider) {
26
26
  const applicableBlockJsonFiles = {};
27
27
  const blockJsonOriginToOutputMapping = {};
28
+ const staticallyLoadedEntrypoints = [];
28
29
  const relevantEntrypoints = this.getRelevantEntrypoints(compilation).toArray();
29
30
  for (const { entrypoint, metadata, srcPath } of relevantEntrypoints) {
31
+ staticallyLoadedEntrypoints.push(...entrypoint.getEntrypointChunk().files);
30
32
  if ((0, node_path_1.basename)(srcPath).toLowerCase() !== "block.json" || !('purpose' in metadata) || metadata.purpose !== "block-json-inclusion-assurance") {
31
33
  continue;
32
34
  }
@@ -64,6 +66,9 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
64
66
  .map(([file, assetType]) => {
65
67
  const enqueuingFlags = (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, metadata.enqueuingFlags, this.dest.enqueuingFlags);
66
68
  const { scriptArgsObject, inlinedAsset } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, enqueuingFlags);
69
+ if (inlinedAsset !== undefined) {
70
+ staticallyLoadedEntrypoints.push(file);
71
+ }
67
72
  const wasOriginallyAStyleField = (0, shared_1.isStyleField)(metadata.entrypointField);
68
73
  const outputPath = this.stripOffBlocksDestPrefix(file);
69
74
  if (wasOriginallyAStyleField !== (assetType === "style")) { // This means that the file is extracted
@@ -108,7 +113,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
108
113
  UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, Object.keys(applicableBlockJsonFiles).length ? {
109
114
  group: this.group,
110
115
  requiresBaseURI: false,
111
- staticallyLoadedEntrypoints: relevantEntrypoints.flatMap(re => re.entrypoint.getEntrypointChunk().files.values().toArray()),
116
+ staticallyLoadedEntrypoints,
112
117
  action
113
118
  } : undefined);
114
119
  }
@@ -20,8 +20,12 @@ class ExtensionsConfigFileGeneratorPluginV1 extends AbstractBiPhasicGroupAndEntr
20
20
  processAssets(compilation, parsedAssetJsonProvider) {
21
21
  const regex = /^(.+?)-((?<prefix>editor-|view-|)(?<type>style|script|script-module))\.(?<extension>css|m?js)$/i;
22
22
  const mapping = {};
23
+ const prefix = this.extensionsDest + node_path_1.default.sep;
23
24
  for (let fileWithAssetData of Object.keys(this.extractRelevantAssetData(compilation, parsedAssetJsonProvider))) {
24
25
  let match;
26
+ if (fileWithAssetData.startsWith(prefix)) {
27
+ fileWithAssetData = fileWithAssetData.substring(prefix.length);
28
+ }
25
29
  if ((match = regex.exec(fileWithAssetData)) && match[1] && match[2]) {
26
30
  if (match.groups?.['type'] === 'style' && match.groups['extension'] !== 'css') {
27
31
  fileWithAssetData = fileWithAssetData.replace(/\.m?js$/i, ".css");
@@ -3,7 +3,7 @@ import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
3
3
  import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
4
4
  import { PseudoSemaphore } from "../utils/pseduo-semaphore";
5
5
  import { Compilation } from "webpack";
6
- type LoaderInfo = {
6
+ export type LoaderInfo = {
7
7
  group: string;
8
8
  action(writer: PHPWriter): void;
9
9
  requiresBaseURI: boolean;
@@ -18,4 +18,3 @@ export declare class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin
18
18
  private withDistDevLoader;
19
19
  private ensureDistExists;
20
20
  }
21
- export {};
package/dist/shared.js CHANGED
@@ -327,7 +327,14 @@ function appendAddInlineAssetCall(compilation, writer, handle, type, inlinedAsse
327
327
  if (handleData.rest[0]?.length) { // If there are any dependencies
328
328
  compilation.errors.push(newWebpackErrorForFile("Inlined scripts MUST NOT have dependencies. It WILL cause runtime inconsistencies and potentially cause sever performance issues", handleData.src));
329
329
  }
330
- const args = [handle, new expressions_1.HereOrNowDoc(`plaudit_inlined_${type}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, inlinedAsset.contents, false)];
330
+ let contents;
331
+ if (compilation.outputOptions.path?.endsWith("-dev")) {
332
+ contents = inlinedAsset.contents;
333
+ }
334
+ else {
335
+ contents = inlinedAsset.contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
336
+ }
337
+ const args = [handle, new expressions_1.HereOrNowDoc(`plaudit_inlined_${type}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false)];
331
338
  if (type === 'script' && inlinedAsset.position === 'before') {
332
339
  args.push('before');
333
340
  }
@@ -148,8 +148,9 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
148
148
  const [entrypointPath, rawLocalPathQueryParameters] = (0, path_query_and_related_helpers_1.unpackPotentiallyPrefixedFilePath)(originalValue);
149
149
  const absoluteSrc = (0, node_path_1.normalize)((0, node_path_1.join)(dir, entrypointPath));
150
150
  filesRegisteredByJson.push(absoluteSrc);
151
+ const parsedFilename = (0, location_encoding_filename_parser_1.parseLocationEncodingFilenameForBlock)(absoluteSrc);
151
152
  const { flags: localEnqueuingFlags, handle, remainder: localPathQueryParameters } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(rawLocalPathQueryParameters, absoluteSrc, "path query parameters");
152
- const enqueuingFlags = (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(absoluteSrc, localEnqueuingFlags, dest.enqueuingFlags);
153
+ const enqueuingFlags = (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(absoluteSrc, localEnqueuingFlags, parsedFilename?.flags, dest.enqueuingFlags);
153
154
  const pathQueryParameters = { ...dest.pathQueryParameters, ...localPathQueryParameters };
154
155
  try {
155
156
  const stats = await (0, promises_1.stat)(absoluteSrc);
@@ -173,7 +174,7 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
173
174
  }
174
175
  const absoluteSrc = (0, node_path_1.normalize)((0, node_path_1.join)(dir, dirent.name));
175
176
  if (filesRegisteredByJson.includes(absoluteSrc)) {
176
- continue; //TODO: Should we make it so that encoded location data is merged in for files loaded via block.json?
177
+ continue;
177
178
  }
178
179
  const parsedFilename = (0, location_encoding_filename_parser_1.parseLocationEncodingFilenameForBlock)(absoluteSrc);
179
180
  if (!parsedFilename) {
@@ -36,7 +36,7 @@ export type NormalizedEnqueuingControlFlags = {
36
36
  fetchpriority?: FetchPriority;
37
37
  position?: 'before' | 'after';
38
38
  };
39
- export declare function mergeTwoEnqueuingControlFlagSets(file: string, baseArgs: NormalizedEnqueuingControlFlags | undefined, ancestorArgs: NormalizedEnqueuingControlFlags | undefined): NormalizedEnqueuingControlFlags | undefined;
39
+ export declare function mergeTwoEnqueuingControlFlagSets(file: string, ...argsBlocks: (NormalizedEnqueuingControlFlags | undefined)[]): NormalizedEnqueuingControlFlags | undefined;
40
40
  export declare function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters: PathQueryParameters | undefined, file: string, sourceType: 'registerScriptArgs' | 'path query parameters'): {
41
41
  flags?: NormalizedEnqueuingControlFlags;
42
42
  handle?: string;
@@ -102,25 +102,28 @@ function isValidPositionForInlineStrategy(position) {
102
102
  function newInvalidPositionForInlineStrategyError(position, file) {
103
103
  return (0, shared_1.newWebpackErrorForFile)(`The position value for the inlined asset was invalid. Received: ${position}, Expected: undefined|'before'|'after'`, file);
104
104
  }
105
- function mergeTwoEnqueuingControlFlagSets(file, baseArgs, ancestorArgs) {
106
- if (baseArgs === undefined) {
107
- return ancestorArgs;
105
+ function mergeTwoEnqueuingControlFlagSets(file, ...argsBlocks) {
106
+ const filteredArgsBlocks = argsBlocks.filter(argsBlock => argsBlock !== undefined);
107
+ if (filteredArgsBlocks.length === 0) {
108
+ return undefined;
108
109
  }
109
- if (ancestorArgs === undefined) {
110
- return baseArgs;
110
+ if ((0, shared_1.arrayIsLength)(filteredArgsBlocks, 1)) {
111
+ return filteredArgsBlocks[0];
111
112
  }
112
- // This must be kept in sync with NormalizedScriptEnqueuingControlFlags
113
+ const res = {};
113
114
  for (const key of ['strategy', 'in_footer', 'fetchpriority', 'inline', 'position']) {
114
- if (key in baseArgs) {
115
- if (key in ancestorArgs && ancestorArgs[key] !== baseArgs[key]) {
116
- throw (0, shared_1.newWebpackErrorForFile)(`The ${key} values in the registerScriptArgs and the pathQueryParameters for the file conflict`, file);
115
+ for (const argsBlock of filteredArgsBlocks) {
116
+ if (key in argsBlock) {
117
+ if (!(key in res)) {
118
+ res[key] = argsBlock[key];
119
+ }
120
+ else if (argsBlock[key] !== res[key]) {
121
+ throw (0, shared_1.newWebpackErrorForFile)(`The ${key} values in the control flag sets for the file conflict`, file);
122
+ }
117
123
  }
118
124
  }
119
- else if (key in ancestorArgs) {
120
- baseArgs[key] = ancestorArgs[key];
121
- }
122
125
  }
123
- return baseArgs;
126
+ return res;
124
127
  }
125
128
  function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters, file, sourceType) {
126
129
  if (pathQueryParameters === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "3.5.2",
3
+ "version": "3.6.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -28,9 +28,9 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@plaudit/gutenberg-api-extensions": "^2.89.0",
31
+ "@plaudit/gutenberg-api-extensions": "^2.90.1",
32
32
  "@types/browser-sync-webpack-plugin": "^2.2.5",
33
- "@types/node": "^25.5.0",
33
+ "@types/node": "^25.5.2",
34
34
  "@types/postcss-functions": "^4.0.4",
35
35
  "@types/postcss-import": "^14.0.3",
36
36
  "@types/tapable": "^2.3.0",
@@ -43,8 +43,8 @@
43
43
  "@plaudit/postcss-color-function": "^5.0.0",
44
44
  "@plaudit/postcss-strip-units": "^3.0.0",
45
45
  "@plaudit/postcss-variables": "^2.0.1",
46
- "@wordpress/dependency-extraction-webpack-plugin": "^6.42.0",
47
- "@wordpress/scripts": "^31.7.0",
46
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.43.0",
47
+ "@wordpress/scripts": "^31.8.0",
48
48
  "autoprefixer": "^10.4.27",
49
49
  "browser-sync": "^3.0.4",
50
50
  "copy-webpack-plugin": "10.2.4",