@plaudit/webpack-extensions 2.90.1 → 2.91.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 +4 -0
- package/dist/plugins/EnhancedBlockJSONPlugin.d.ts +1 -1
- package/dist/plugins/EnhancedBlockJSONPlugin.js +22 -11
- package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.js +3 -2
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +3 -2
- package/dist/shared.d.ts +7 -0
- package/dist/shared.js +30 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -60,6 +60,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
60
60
|
- Legacy PostCSS features that have been integrated into modern CSS
|
|
61
61
|
- `@extends` support
|
|
62
62
|
|
|
63
|
+
## [2.91.0] - 2026-05-20
|
|
64
|
+
### Added
|
|
65
|
+
- Support for the `module_dependencies` property on `script` assets
|
|
66
|
+
|
|
63
67
|
## [2.90.1] - 2026-05-08
|
|
64
68
|
### Fixed
|
|
65
69
|
- `postcss-loader` being a dev dependency
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Compilation } from "webpack";
|
|
2
2
|
import type WebpackRemoveEmptyScriptsPlugin from "webpack-remove-empty-scripts";
|
|
3
3
|
import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
|
|
4
|
-
import {
|
|
4
|
+
import { BlockEntrypointInfo, FileSegmentBlockEntrypointInfo, InlinedAsset, ParsedAssetJsonProvider, ParsedAssetsJson, ScriptArgsObject, VerifiedAdvancedOutputConfig } from "../shared";
|
|
5
5
|
import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
|
|
6
6
|
type WorkableBlockEntrypointInfo = Omit<FileSegmentBlockEntrypointInfo, 'originalValue' | 'pathQueryParameters'> & Partial<Pick<FileSegmentBlockEntrypointInfo, 'originalValue'>> & {
|
|
7
7
|
outputPath: string;
|
|
@@ -237,21 +237,32 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
|
|
|
237
237
|
}
|
|
238
238
|
static convertToScriptHandles(handleData) {
|
|
239
239
|
return handleData.map(hd => {
|
|
240
|
-
const
|
|
240
|
+
const { inlinedAsset, originalValue, outputPath, entrypointField, scriptArgsObject: rawScriptArgsObject, assetData, handle } = hd;
|
|
241
|
+
const { dependencies = [], module_dependencies = undefined } = originalValue !== undefined ? assetData : {};
|
|
241
242
|
let scriptArgsObject;
|
|
242
|
-
if (
|
|
243
|
-
scriptArgsObject =
|
|
244
|
-
}
|
|
245
|
-
else if (hd.inlinedAsset !== undefined) {
|
|
246
|
-
scriptArgsObject = hd.inlinedAsset.position === 'before' ? { strategy: "defer" } : undefined;
|
|
247
|
-
}
|
|
248
|
-
else if (!hd.entrypointField.startsWith("editor")) {
|
|
249
|
-
scriptArgsObject = { strategy: "defer" };
|
|
243
|
+
if (rawScriptArgsObject !== undefined) {
|
|
244
|
+
scriptArgsObject = { ...rawScriptArgsObject, module_dependencies: (0, shared_1.mergeModuleDependencyArrays)(rawScriptArgsObject.module_dependencies, module_dependencies) };
|
|
250
245
|
}
|
|
251
246
|
else {
|
|
252
|
-
|
|
247
|
+
if (inlinedAsset !== undefined) {
|
|
248
|
+
scriptArgsObject = inlinedAsset.position === 'before' ? { strategy: "defer" } : undefined;
|
|
249
|
+
}
|
|
250
|
+
else if (!entrypointField.startsWith("editor")) {
|
|
251
|
+
scriptArgsObject = { strategy: "defer" };
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
scriptArgsObject = undefined;
|
|
255
|
+
}
|
|
256
|
+
if (module_dependencies?.length) {
|
|
257
|
+
if (scriptArgsObject === undefined) {
|
|
258
|
+
scriptArgsObject = { module_dependencies };
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
scriptArgsObject.module_dependencies = module_dependencies;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
253
264
|
}
|
|
254
|
-
return [
|
|
265
|
+
return [handle, { src: outputPath, rest: scriptArgsObject !== undefined ? [dependencies, assetData.version, scriptArgsObject] : [dependencies, assetData.version], inlinedAsset }];
|
|
255
266
|
});
|
|
256
267
|
}
|
|
257
268
|
static doFileOrHandleReplacements(compilation, blockJson, workableBlockEntrypointsInfo, getter) {
|
|
@@ -96,11 +96,12 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
|
|
|
96
96
|
const isCss = (0, shared_1.isStyleField)(assetType);
|
|
97
97
|
const handleGroup = isCss ? 'styleHandles'
|
|
98
98
|
: ((0, shared_1.isScriptModuleField)(assetType) ? 'scriptModuleHandles' : 'scriptHandles');
|
|
99
|
+
const { dependencies, module_dependencies } = assetData;
|
|
99
100
|
blockExtensionsConfig[handleGroup][handle] = {
|
|
100
101
|
src: isCss ? assetPath.replace(/\.js$/, ".css") : assetPath,
|
|
101
102
|
rest: isCss || key.startsWith("editor")
|
|
102
|
-
? [assetData.dependencies, assetData.version]
|
|
103
|
-
: [
|
|
103
|
+
? (module_dependencies?.length ? [dependencies, assetData.version, { in_footer: true, module_dependencies }] : [dependencies, assetData.version])
|
|
104
|
+
: [dependencies, assetData.version, { strategy: 'defer', module_dependencies: module_dependencies?.length ? module_dependencies : undefined }]
|
|
104
105
|
};
|
|
105
106
|
(blockExtensionsConfig.blocks[blockSlug] ?? (blockExtensionsConfig.blocks[blockSlug] = {}))[key] = handle;
|
|
106
107
|
}
|
|
@@ -297,11 +297,12 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
297
297
|
const extension = (0, node_path_1.extname)(file).toLowerCase();
|
|
298
298
|
const type = extension === ".js" ? 'script' : (extension === ".mjs" ? 'script_module' : 'style');
|
|
299
299
|
const isScript = type !== 'style';
|
|
300
|
-
const dependencies = isScript === entrypointChunkIsScript ? assetData
|
|
300
|
+
const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
|
|
301
301
|
const { lazyLoader, locations } = this.dest;
|
|
302
302
|
const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
|
|
303
303
|
const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags));
|
|
304
|
-
const
|
|
304
|
+
const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
|
|
305
|
+
const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
|
|
305
306
|
const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
|
|
306
307
|
handles.push({
|
|
307
308
|
src: destPath,
|
package/dist/shared.d.ts
CHANGED
|
@@ -4,15 +4,21 @@ import { type AssetInfo, type Compilation, type Configuration, type Entrypoint,
|
|
|
4
4
|
import { SourceType } from "./utils/entrypoint-resolution-logic";
|
|
5
5
|
import type { NormalizedEnqueuingControlFlags } from "./utils/path-query-and-related-helpers";
|
|
6
6
|
export * from "./utils/entrypoint-resolution-logic";
|
|
7
|
+
export type WPModuleDependency = {
|
|
8
|
+
id: string;
|
|
9
|
+
import?: string;
|
|
10
|
+
};
|
|
7
11
|
export type ParsedAssetsJson = Record<string, {
|
|
8
12
|
dependencies: string[];
|
|
9
13
|
version: string;
|
|
14
|
+
module_dependencies?: (string | WPModuleDependency)[];
|
|
10
15
|
}>;
|
|
11
16
|
export declare function isParsedAssetsJson(thing: any): thing is ParsedAssetsJson;
|
|
12
17
|
export type ScriptArgsObject = {
|
|
13
18
|
strategy?: 'defer' | 'async';
|
|
14
19
|
in_footer?: boolean;
|
|
15
20
|
fetchpriority?: 'auto' | 'low' | 'high';
|
|
21
|
+
module_dependencies?: (string | WPModuleDependency)[];
|
|
16
22
|
};
|
|
17
23
|
type BaseRestType = [/* dependencies: */ string[], /* version: */ string];
|
|
18
24
|
export type InlinedAsset = {
|
|
@@ -212,6 +218,7 @@ export declare const styleExtension: RegExp;
|
|
|
212
218
|
export declare function scriptOrStyleTest(entryPath: string, scriptExtension: RegExp): "script" | "style" | "";
|
|
213
219
|
export declare function isStyleField(field: string): field is 'style' | 'viewStyle' | 'editorStyle';
|
|
214
220
|
export declare function isScriptModuleField(field: string): field is 'viewScriptModule';
|
|
221
|
+
export declare function mergeModuleDependencyArrays(a: (string | WPModuleDependency)[] | undefined, b: (string | WPModuleDependency)[] | undefined): (string | WPModuleDependency)[] | undefined;
|
|
215
222
|
export declare function getHandleGroup(field: string): 'styleHandles' | 'scriptHandles' | 'scriptModuleHandles';
|
|
216
223
|
export type StripFirstTwoItems<A extends any[]> = A extends [any, any, ...rest: infer R] ? R : never;
|
|
217
224
|
export declare function hasAtLeastOneItem<T>(list: T[]): list is [T, ...T[]];
|
package/dist/shared.js
CHANGED
|
@@ -34,6 +34,7 @@ exports.leadingSlashIt = leadingSlashIt;
|
|
|
34
34
|
exports.scriptOrStyleTest = scriptOrStyleTest;
|
|
35
35
|
exports.isStyleField = isStyleField;
|
|
36
36
|
exports.isScriptModuleField = isScriptModuleField;
|
|
37
|
+
exports.mergeModuleDependencyArrays = mergeModuleDependencyArrays;
|
|
37
38
|
exports.getHandleGroup = getHandleGroup;
|
|
38
39
|
exports.hasAtLeastOneItem = hasAtLeastOneItem;
|
|
39
40
|
exports.arrayIsLength = arrayIsLength;
|
|
@@ -65,7 +66,7 @@ function isParsedAssetsJson(thing) {
|
|
|
65
66
|
}
|
|
66
67
|
for (const value of Object.values(thing)) {
|
|
67
68
|
if ((!value || typeof value !== 'object') ||
|
|
68
|
-
(!('dependencies' in value) || !Array.isArray(value.dependencies) || value.dependencies.
|
|
69
|
+
(!('dependencies' in value) || !Array.isArray(value.dependencies) || (value.dependencies.length > 0 && !value.dependencies.every(d => typeof d === 'string' || (d && typeof d === 'object' && typeof d.id === 'string')))) ||
|
|
69
70
|
(!('version' in value) || !value.version || typeof value.version !== 'string')) {
|
|
70
71
|
return false;
|
|
71
72
|
}
|
|
@@ -174,6 +175,34 @@ function isStyleField(field) {
|
|
|
174
175
|
function isScriptModuleField(field) {
|
|
175
176
|
return field.includes("odule");
|
|
176
177
|
}
|
|
178
|
+
function mergeModuleDependencyArrays(a, b) {
|
|
179
|
+
if (a === undefined || a.length === 0) {
|
|
180
|
+
return b;
|
|
181
|
+
}
|
|
182
|
+
if (b === undefined || b.length === 0) {
|
|
183
|
+
return a;
|
|
184
|
+
}
|
|
185
|
+
const seenModuleDeps = new Map();
|
|
186
|
+
return [...a, ...b].filter(dep => {
|
|
187
|
+
let id, type;
|
|
188
|
+
if (typeof dep === 'string') {
|
|
189
|
+
id = dep;
|
|
190
|
+
type = 'static';
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
id = dep.id;
|
|
194
|
+
type = dep.import ?? 'static';
|
|
195
|
+
}
|
|
196
|
+
if (seenModuleDeps.has(id)) {
|
|
197
|
+
if (type !== seenModuleDeps.get(id)) {
|
|
198
|
+
throw newCleanWebpackError(`Encountered conflicting import types for the "${id}" module dependency`);
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
seenModuleDeps.set(id, type);
|
|
203
|
+
return true;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
177
206
|
function getHandleGroup(field) {
|
|
178
207
|
if (isStyleField(field)) {
|
|
179
208
|
return 'styleHandles';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.91.0",
|
|
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.97.
|
|
31
|
+
"@plaudit/gutenberg-api-extensions": "^2.97.1",
|
|
32
32
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
33
|
-
"@types/node": "^25.
|
|
33
|
+
"@types/node": "^25.9.1",
|
|
34
34
|
"@types/postcss-functions": "^4.0.4",
|
|
35
35
|
"@types/tapable": "^2.3.0",
|
|
36
36
|
"@types/webpack-sources": "^3.2.3",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
45
45
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
46
46
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
47
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
48
|
-
"@wordpress/scripts": "^32.
|
|
47
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.46.0",
|
|
48
|
+
"@wordpress/scripts": "^32.2.0",
|
|
49
49
|
"autoprefixer": "^10.5.0",
|
|
50
50
|
"browser-sync": "^3.0.4",
|
|
51
51
|
"copy-webpack-plugin": "10.2.4",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
54
54
|
"http-proxy-middleware": "^3.0.5",
|
|
55
55
|
"json2php": "^0.0.12",
|
|
56
|
-
"postcss": "^8.5.
|
|
56
|
+
"postcss": "^8.5.15",
|
|
57
57
|
"postcss-calc": "^9.0.1",
|
|
58
58
|
"postcss-discard-comments": "^6.0.2",
|
|
59
59
|
"postcss-functions": "^4.0.2",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"postcss-reporter": "^7.1.0",
|
|
68
68
|
"postcss-simple-vars": "^7.0.1",
|
|
69
69
|
"postcss-url": "^10.1.3",
|
|
70
|
-
"webpack": "^5.
|
|
70
|
+
"webpack": "^5.107.0",
|
|
71
71
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
72
72
|
"xml-formatter": "^3.7.0"
|
|
73
73
|
},
|