@plaudit/webpack-extensions 3.5.1 → 3.6.0
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 +29 -0
- package/USER-GUIDE.md +4 -4
- package/dist/plugins/EnhancedBlockJSONPlugin.js +6 -1
- package/dist/plugins/UnifiedLoaderGenerator.d.ts +1 -2
- package/dist/shared.js +8 -1
- package/dist/utils/common-config-helpers.js +4 -3
- package/dist/utils/path-query-and-related-helpers.d.ts +1 -1
- package/dist/utils/path-query-and-related-helpers.js +16 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,26 @@ 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.0] - 2026-03-31
|
|
9
|
+
### Changed
|
|
10
|
+
- The block.json handling logic to use encoded location data in filenames that are enumerated within block.json
|
|
11
|
+
- This comes from version `2.89.0`
|
|
12
|
+
- Inline scripts to not emit with a sourcemap outside of dev mode
|
|
13
|
+
- This comes from version `2.89.0`
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Unnecessary `.asset.php` files being emitted for inlined scripts
|
|
17
|
+
- This comes from version `2.89.0`
|
|
18
|
+
|
|
19
|
+
## [3.5.2] - 2026-03-30
|
|
20
|
+
### Fixed
|
|
21
|
+
- The conflicting handle detection logic in block.json handling
|
|
22
|
+
- This comes from version `2.88.2`
|
|
23
|
+
|
|
8
24
|
## [3.5.1] - 2026-03-30
|
|
9
25
|
### Fixed
|
|
10
26
|
- The paths in package.json that were broken after switching to dist
|
|
27
|
+
- This comes from version `2.88.1`
|
|
11
28
|
|
|
12
29
|
## [3.5.0] - 2026-03-30
|
|
13
30
|
### Added
|
|
@@ -80,6 +97,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
80
97
|
- Legacy PostCSS features that have been integrated into modern CSS
|
|
81
98
|
- `@extends` support
|
|
82
99
|
|
|
100
|
+
## [2.89.0] - 2026-03-31
|
|
101
|
+
### Changed
|
|
102
|
+
- The block.json handling logic to use encoded location data in filenames that are enumerated within block.json
|
|
103
|
+
- Inline scripts to not emit with a sourcemap outside of dev mode
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
- Unnecessary `.asset.php` files being emitted for inlined scripts
|
|
107
|
+
|
|
108
|
+
## [2.88.2] - 2026-03-30
|
|
109
|
+
### Fixed
|
|
110
|
+
- The conflicting handle detection logic in block.json handling
|
|
111
|
+
|
|
83
112
|
## [2.88.1] - 2026-03-30
|
|
84
113
|
### Fixed
|
|
85
114
|
- The paths in package.json that were broken after switching to dist
|
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
|
|
349
|
-
- Each file can
|
|
350
|
-
- The first item is special in that, if it encodes a location,
|
|
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
|
|
116
|
+
staticallyLoadedEntrypoints,
|
|
112
117
|
action
|
|
113
118
|
} : undefined);
|
|
114
119
|
}
|
|
@@ -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
|
-
|
|
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;
|
|
177
|
+
continue;
|
|
177
178
|
}
|
|
178
179
|
const parsedFilename = (0, location_encoding_filename_parser_1.parseLocationEncodingFilenameForBlock)(absoluteSrc);
|
|
179
180
|
if (!parsedFilename) {
|
|
@@ -305,7 +306,7 @@ function resolveEntryFromDirectory(commonConfig, srcRoot, dest) {
|
|
|
305
306
|
const perAssetPathGroupedEntrypoints = groupEntrypointsByAssetFile(allEntrypoints.flatMap(e => e[0]), e => e[0]);
|
|
306
307
|
const conflictingHandles = Object.values(seenExplicitHandles)
|
|
307
308
|
.flatMap(handles => Object.entries(handles))
|
|
308
|
-
.filter(([, sources]) => sources.length >
|
|
309
|
+
.filter(([, sources]) => sources.length > 1)
|
|
309
310
|
.map(([handle, sources]) => `${handle}: ${sources.join(", ")}`);
|
|
310
311
|
if (conflictingHandles.length > 0) {
|
|
311
312
|
throw (0, shared_1.newCleanWebpackError)("Encountered conflicting explicitly-set handles:\n" + conflictingHandles.join("\n"));
|
|
@@ -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,
|
|
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,
|
|
106
|
-
|
|
107
|
-
|
|
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 (
|
|
110
|
-
return
|
|
110
|
+
if ((0, shared_1.arrayIsLength)(filteredArgsBlocks, 1)) {
|
|
111
|
+
return filteredArgsBlocks[0];
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
const res = {};
|
|
113
114
|
for (const key of ['strategy', 'in_footer', 'fetchpriority', 'inline', 'position']) {
|
|
114
|
-
|
|
115
|
-
if (key in
|
|
116
|
-
|
|
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
|
|
126
|
+
return res;
|
|
124
127
|
}
|
|
125
128
|
function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters, file, sourceType) {
|
|
126
129
|
if (pathQueryParameters === undefined) {
|