@plaudit/webpack-extensions 2.99.1 → 2.99.3
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 +13 -0
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +31 -27
- package/dist/shared.d.ts +14 -6
- package/dist/shared.js +19 -3
- package/dist/utils/location-encoding-filename-parser.d.ts +4 -4
- package/dist/utils/location-encoding-filename-parser.js +12 -16
- package/dist/wordpress-scripts-wrapper.js +4 -6
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -60,6 +60,19 @@ 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.99.3] - 2026-09-04
|
|
64
|
+
### Fixed
|
|
65
|
+
- The `inline` flag not getting picked up if it was set from within the webpack.config.js file
|
|
66
|
+
- Inlined assets getting put in the registered assets list
|
|
67
|
+
- An unnecessary call to `plaudit_webpack_extensions__resolve_base_uri` being emitted when a "registration" batch exclusively contains inlined assets
|
|
68
|
+
|
|
69
|
+
### Internals
|
|
70
|
+
- Tweaked a few things to make adding new enqueue locations easier
|
|
71
|
+
|
|
72
|
+
## [2.99.2] - 2026-09-01
|
|
73
|
+
### Removed
|
|
74
|
+
- The duplicated `isDistDevOutputPath` logic around the initialization of the `@plaudit/dev-webpack-plugin`
|
|
75
|
+
|
|
63
76
|
## [2.99.1] - 2026-08-26
|
|
64
77
|
### Internals
|
|
65
78
|
- Updated to the 34.x line of `@wordpress/scripts`
|
|
@@ -71,32 +71,36 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
71
71
|
list.sort(callItemSorter);
|
|
72
72
|
}
|
|
73
73
|
const writer = new php_writer_1.PHPWriter();
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const hasRegisterScripts = handleLists.register.length > 0;
|
|
75
|
+
if (hasRegisterScripts || handleLists.inline.length > 0) {
|
|
76
|
+
if (hasRegisterScripts && !this.useUnifiedLoader) {
|
|
76
77
|
(0, shared_1.emitResolveBaseUriFunction)(writer);
|
|
77
78
|
}
|
|
78
79
|
const baseUriVar = new expressions_1.Var("base_uri");
|
|
79
|
-
|
|
80
|
+
const inlineAndRegisterHandleLists = [
|
|
81
|
+
...handleLists.register.map(handleItem => ({ ...handleItem, handleGroup: 'register' })),
|
|
82
|
+
...handleLists.inline.map(handleItem => ({ ...handleItem, handleGroup: 'inline' })),
|
|
83
|
+
];
|
|
84
|
+
for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(inlineAndRegisterHandleLists)) {
|
|
80
85
|
writer.action("init", writer => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (data.inlinedAsset !== undefined) {
|
|
84
|
-
writer.call(`wp_register_${type}`, [handle, false, ...data.rest]);
|
|
85
|
-
(0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, data);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
writer.call(`wp_register_${type}`, [handle, expressions_1.Op.concat(baseUriVar, (0, node_path_1.relative)(emitDir, data.src)), ...data.rest]);
|
|
89
|
-
}
|
|
86
|
+
if (prioritizedHandleList.find(handleItem => handleItem.data.inlinedAsset === undefined)) {
|
|
87
|
+
writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
for (const { data, handle, handleGroup, type } of prioritizedHandleList) {
|
|
90
|
+
if (handleGroup === 'register') {
|
|
91
|
+
if (data.inlinedAsset !== undefined) {
|
|
92
|
+
writer.call(`wp_register_${type}`, [handle, false, ...data.rest]);
|
|
93
|
+
(0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, data);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
writer.call(`wp_register_${type}`, [handle, expressions_1.Op.concat(baseUriVar, (0, node_path_1.relative)(emitDir, data.src)), ...data.rest]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (handleGroup === 'inline') {
|
|
100
|
+
writer.call(`wp_register_${type}`, [handle, false, ...data.rest]);
|
|
101
|
+
if (data.inlinedAsset !== undefined) {
|
|
102
|
+
(0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, data);
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
}, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
|
|
@@ -149,12 +153,12 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
149
153
|
static addHandlesToHandleLists(compilation, type, handles, handleLists) {
|
|
150
154
|
const defaultPriority = 10;
|
|
151
155
|
for (const [handle, data] of handles) {
|
|
152
|
-
if (data.
|
|
153
|
-
handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
|
|
154
|
-
}
|
|
155
|
-
else if (data.inlinedAsset !== undefined) {
|
|
156
|
+
if (data.inlinedAsset !== undefined) {
|
|
156
157
|
handleLists.inline.push({ handle, type, data, priority: typeof data.locations.inline === 'number' ? data.locations.inline : 10 });
|
|
157
158
|
}
|
|
159
|
+
else if (data.locations.register !== false) {
|
|
160
|
+
handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
|
|
161
|
+
}
|
|
158
162
|
if (data.lazyLoader !== undefined) {
|
|
159
163
|
// A lazily loaded handle is enqueued by its generated function and never by an action, so it
|
|
160
164
|
// is deliberately kept out of the location lists. Those lists are also what the lazy function
|
|
@@ -211,7 +215,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
211
215
|
}
|
|
212
216
|
}
|
|
213
217
|
static appendEnqueuingHandleLists(writer, handleLists) {
|
|
214
|
-
for (const [sln, { action, supports_hook_name, additional_action_code }] of (0, shared_1.
|
|
218
|
+
for (const [sln, { action, supports_hook_name, additional_action_code }] of (0, shared_1.iterableStandardLocationNamesMeta)()) {
|
|
215
219
|
const handleList = handleLists[sln];
|
|
216
220
|
if (handleList.length > 0) {
|
|
217
221
|
writer.linebreak();
|
|
@@ -320,7 +324,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
320
324
|
const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
|
|
321
325
|
const { lazyLoader, locations } = this.dest;
|
|
322
326
|
const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
|
|
323
|
-
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));
|
|
327
|
+
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));
|
|
324
328
|
const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
|
|
325
329
|
const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
|
|
326
330
|
const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
|
package/dist/shared.d.ts
CHANGED
|
@@ -41,15 +41,26 @@ export type HandleData = BaseHandleData & (AssetMetaSegment | {
|
|
|
41
41
|
inlinedAsset?: undefined;
|
|
42
42
|
assetContents?: string;
|
|
43
43
|
});
|
|
44
|
+
type OptionalLocationMeta = {
|
|
45
|
+
supports_hook_name?: boolean;
|
|
46
|
+
additional_action_code?: {
|
|
47
|
+
before?(writer: PHPWriter): unknown;
|
|
48
|
+
after?(writer: PHPWriter): unknown;
|
|
49
|
+
};
|
|
50
|
+
alternate_names?: [string, ...string[]];
|
|
51
|
+
};
|
|
44
52
|
export declare const standardLocationNamesMeta: {
|
|
45
53
|
readonly clientView: {
|
|
46
54
|
readonly action: "wp_enqueue_scripts";
|
|
55
|
+
readonly alternate_names: ["client-view", "view"];
|
|
47
56
|
};
|
|
48
57
|
readonly clientEditor: {
|
|
49
58
|
readonly action: "enqueue_block_editor_assets";
|
|
59
|
+
readonly alternate_names: ["client-editor", "editor"];
|
|
50
60
|
};
|
|
51
61
|
readonly blockAssets: {
|
|
52
62
|
readonly action: "enqueue_block_assets";
|
|
63
|
+
readonly alternate_names: ["block-assets"];
|
|
53
64
|
};
|
|
54
65
|
readonly admin: {
|
|
55
66
|
readonly action: "admin_enqueue_scripts";
|
|
@@ -67,14 +78,11 @@ export declare const standardLocationNamesMeta: {
|
|
|
67
78
|
};
|
|
68
79
|
export type StandardLocationNameMeta = {
|
|
69
80
|
action: typeof standardLocationNamesMeta[keyof typeof standardLocationNamesMeta]['action'];
|
|
70
|
-
|
|
71
|
-
additional_action_code?: {
|
|
72
|
-
before?(writer: PHPWriter): unknown;
|
|
73
|
-
after?(writer: PHPWriter): unknown;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
81
|
+
} & OptionalLocationMeta;
|
|
76
82
|
export type StandardLocationNames = keyof typeof standardLocationNamesMeta;
|
|
77
83
|
export declare function isStandardLocationName(name: string): name is StandardLocationNames;
|
|
84
|
+
export declare function iterableStandardLocationNamesMeta(): [StandardLocationNames, StandardLocationNameMeta][];
|
|
85
|
+
export declare function normalizeLocationName(name: string): StandardLocationNames | 'register';
|
|
78
86
|
type LocationWithHookNameSupport = boolean | number | string | string[] | {
|
|
79
87
|
hook_name?: string | string[];
|
|
80
88
|
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.constantKeys = constantKeys;
|
|
@@ -75,9 +77,9 @@ function isParsedAssetsJson(thing) {
|
|
|
75
77
|
return true;
|
|
76
78
|
}
|
|
77
79
|
exports.standardLocationNamesMeta = {
|
|
78
|
-
clientView: { action: "wp_enqueue_scripts" },
|
|
79
|
-
clientEditor: { action: "enqueue_block_editor_assets" },
|
|
80
|
-
blockAssets: { action: "enqueue_block_assets" },
|
|
80
|
+
clientView: { action: "wp_enqueue_scripts", alternate_names: ['client-view', 'view'] },
|
|
81
|
+
clientEditor: { action: "enqueue_block_editor_assets", alternate_names: ['client-editor', 'editor'] },
|
|
82
|
+
blockAssets: { action: "enqueue_block_assets", alternate_names: ['block-assets'] },
|
|
81
83
|
admin: { action: "admin_enqueue_scripts", supports_hook_name: true },
|
|
82
84
|
login: { action: "login_enqueue_scripts" },
|
|
83
85
|
customizer: { action: "customize_controls_enqueue_scripts" },
|
|
@@ -86,6 +88,20 @@ exports.standardLocationNamesMeta = {
|
|
|
86
88
|
function isStandardLocationName(name) {
|
|
87
89
|
return Object.hasOwn(exports.standardLocationNamesMeta, name);
|
|
88
90
|
}
|
|
91
|
+
function iterableStandardLocationNamesMeta() {
|
|
92
|
+
return constantEntries(exports.standardLocationNamesMeta);
|
|
93
|
+
}
|
|
94
|
+
function normalizeLocationName(name) {
|
|
95
|
+
if (isStandardLocationName(name) || name === 'register') {
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
for (const [standardName, { alternate_names }] of iterableStandardLocationNamesMeta()) {
|
|
99
|
+
if (alternate_names?.includes(name)) {
|
|
100
|
+
return standardName;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`"${name}" is neither a standard nor alternate location name`);
|
|
104
|
+
}
|
|
89
105
|
function isRegisterScriptArgsShorthandName(name) {
|
|
90
106
|
return ['lazy', 'eager', 'inline'].includes(name);
|
|
91
107
|
}
|
|
@@ -13,14 +13,14 @@ export declare function parseLocationEncodingFilenameForBlock(filename: string,
|
|
|
13
13
|
locations: Pick<RealUsageLocations, 'clientEditor' | 'clientView'>;
|
|
14
14
|
}) | undefined;
|
|
15
15
|
/**
|
|
16
|
-
* This handles detecting all keys of standardLocationNamesMeta as well as
|
|
16
|
+
* This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
|
|
17
17
|
* It MUST be kept in sync with standardLocationNamesMeta
|
|
18
18
|
* @param segment
|
|
19
19
|
*/
|
|
20
20
|
export declare function extractLocationFromPropertyEncodingFilenameSegment(segment: string): {
|
|
21
|
+
readonly locationName: false;
|
|
22
|
+
readonly priority?: undefined;
|
|
23
|
+
} | {
|
|
21
24
|
readonly locationName: "admin" | "analytics" | "blockAssets" | "clientEditor" | "clientView" | "customizer" | "login" | "register";
|
|
22
25
|
readonly priority: number | true;
|
|
23
|
-
} | {
|
|
24
|
-
readonly priority?: undefined;
|
|
25
|
-
readonly locationName: false;
|
|
26
26
|
};
|
|
@@ -92,27 +92,23 @@ function parseLocationEncodingFilenameForBlock(filename, errorBuilder = shared_1
|
|
|
92
92
|
}
|
|
93
93
|
return parsedFilename;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
let standardLocationNamesAndPriorityPatternInFilenameSegment;
|
|
96
96
|
/**
|
|
97
|
-
* This handles detecting all keys of standardLocationNamesMeta as well as
|
|
97
|
+
* This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
|
|
98
98
|
* It MUST be kept in sync with standardLocationNamesMeta
|
|
99
99
|
* @param segment
|
|
100
100
|
*/
|
|
101
101
|
function extractLocationFromPropertyEncodingFilenameSegment(segment) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
if (editor) {
|
|
109
|
-
return { locationName: "clientEditor", priority };
|
|
102
|
+
if (!standardLocationNamesAndPriorityPatternInFilenameSegment) {
|
|
103
|
+
const matchableLocationNames = (0, shared_1.iterableStandardLocationNamesMeta)()
|
|
104
|
+
.flatMap(([standardName, { alternate_names = [] }]) => [standardName, ...alternate_names])
|
|
105
|
+
.join("|");
|
|
106
|
+
standardLocationNamesAndPriorityPatternInFilenameSegment = new RegExp(`^(?<locationName>${matchableLocationNames}|register)(?:[-=](?<priority>-?\\d+))?$`);
|
|
110
107
|
}
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
const { locationName, priority: rawPriority } = standardLocationNamesAndPriorityPatternInFilenameSegment.exec(segment)?.groups ?? {};
|
|
109
|
+
if (!locationName) {
|
|
110
|
+
return { locationName: false };
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
return { locationName: false };
|
|
112
|
+
const priority = rawPriority !== undefined ? parseInt(rawPriority) : true;
|
|
113
|
+
return { locationName: (0, shared_1.normalizeLocationName)(locationName), priority };
|
|
118
114
|
}
|
|
@@ -447,13 +447,11 @@ function buildCommonPluginConfig(webpackConfig, config, bundleAnalyzer, assumeGl
|
|
|
447
447
|
}
|
|
448
448
|
const builtDependencyExtractionWebpackPlugin = (0, dependency_extraction_webpack_plugin_config_builder_1.makeDependencyExtractionPlugin)(config.externals, assumeGlobalizedPlauditLibraries, externalize);
|
|
449
449
|
plugins[dependencyExtractionPluginIndex] = builtDependencyExtractionWebpackPlugin;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
plugins.push(new PlauditDevPlugin(config));
|
|
454
|
-
}
|
|
455
|
-
catch { }
|
|
450
|
+
try {
|
|
451
|
+
const { PlauditDevPlugin } = require("@plaudit/dev-webpack-plugin");
|
|
452
|
+
plugins.push(new PlauditDevPlugin(config));
|
|
456
453
|
}
|
|
454
|
+
catch { }
|
|
457
455
|
return {
|
|
458
456
|
plugins, removeEmptyScriptsPlugin,
|
|
459
457
|
makeAdditionalDependencyInjectorPlugin(referencePlugin) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.99.
|
|
3
|
+
"version": "2.99.3",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@plaudit/dev-webpack-plugin": "^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.
|
|
40
|
+
"@types/node": "^26.4.1",
|
|
41
41
|
"@types/postcss-functions": "^4.0.4",
|
|
42
42
|
"@types/tapable": "^2.3.0",
|
|
43
43
|
"@types/webpack-sources": "^3.2.3",
|
|
44
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
44
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.54.0",
|
|
45
45
|
"atob": "^2.1.2",
|
|
46
46
|
"css-loader": "^6.11.0",
|
|
47
47
|
"glob": "^7.2.3",
|
|
48
|
-
"jest": "^30.
|
|
48
|
+
"jest": "^30.5.1",
|
|
49
49
|
"lodash": "^4.18.1",
|
|
50
50
|
"mini-css-extract-plugin": "^2.10.2",
|
|
51
51
|
"mkdirp": "^3.0.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
61
61
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
62
62
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
63
|
-
"@wordpress/scripts": "^34.
|
|
63
|
+
"@wordpress/scripts": "^34.2.0",
|
|
64
64
|
"autoprefixer": "^10.5.4",
|
|
65
65
|
"copy-webpack-plugin": "10.2.4",
|
|
66
66
|
"css-minimizer-webpack-plugin": "^6.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
69
69
|
"jsdom": "^30.0.1",
|
|
70
70
|
"json2php": "0.0.12",
|
|
71
|
-
"postcss": "^8.5.
|
|
71
|
+
"postcss": "^8.5.28",
|
|
72
72
|
"postcss-calc": "^9.0.1",
|
|
73
73
|
"postcss-discard-comments": "^6.0.2",
|
|
74
74
|
"postcss-functions": "^4.0.2",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"postcss-reporter": "^7.1.0",
|
|
83
83
|
"postcss-simple-vars": "^7.0.1",
|
|
84
84
|
"postcss-url": "^10.1.4",
|
|
85
|
-
"webpack": "^5.
|
|
85
|
+
"webpack": "^5.110.3",
|
|
86
86
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
87
87
|
"xml-formatter": "^3.7.0"
|
|
88
88
|
},
|