@plaudit/webpack-extensions 2.92.3 → 2.93.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
CHANGED
|
@@ -60,6 +60,16 @@ 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.93.0] - 2026-07-15
|
|
64
|
+
### Added
|
|
65
|
+
- Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
|
|
66
|
+
- This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
|
|
67
|
+
- The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
|
|
68
|
+
|
|
69
|
+
## [2.92.4] - 2026-06-10
|
|
70
|
+
### Fixed
|
|
71
|
+
- Libraries externalizing in a way that does not account for the variable potentially being undeclared
|
|
72
|
+
|
|
63
73
|
## [2.92.3] - 2026-05-27
|
|
64
74
|
### Fixed
|
|
65
75
|
- A couple more dependency snarls
|
|
@@ -22,6 +22,8 @@ export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEnt
|
|
|
22
22
|
constructor(config: VerifiedPlauditWordpressWebpackConfig, dest: VerifiedAdvancedOutputConfig, webpackRemoveEmptyScriptsPlugin: WebpackRemoveEmptyScriptsPlugin, context: string, entry: EntryProvider<BlockEntrypointInfo>);
|
|
23
23
|
protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): Promise<void>;
|
|
24
24
|
private emitBlockLoaderFile;
|
|
25
|
+
private static readonly IGNORED_THEME_JSON_FLAG_PROPS;
|
|
26
|
+
private static pickOutFlagPropsFromBlockSupports;
|
|
25
27
|
private callRegisterFunction;
|
|
26
28
|
private transformBlocks;
|
|
27
29
|
private static extractAssetSource;
|
|
@@ -34,6 +36,8 @@ export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEnt
|
|
|
34
36
|
static findRelativeRouteBetween(path1: string, path2: string): string;
|
|
35
37
|
private static remapReferencedPHPFilesOnKey;
|
|
36
38
|
private static normalizeRenderTemplate;
|
|
39
|
+
private static readonly knownExperimentalProperties;
|
|
40
|
+
private static handleExperimentalBlockSupportsFlags;
|
|
37
41
|
protected attachUniquePhase(compilation: Compilation): void;
|
|
38
42
|
protected attachStandardPhase(compilation: Compilation): void;
|
|
39
43
|
protected deduplicateEntrypointHandles(workableBlockInfo: CollatedWorkableBlockInfo): CollatedWorkableBlockInfo;
|
|
@@ -196,12 +196,57 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
|
|
|
196
196
|
(0, shared_1.appendAddInlineAssetCall)(compilation, writer, ...inlinableStyle);
|
|
197
197
|
}
|
|
198
198
|
}, { accountForAlreadyDoing: this.config.includePostInitFallback });
|
|
199
|
+
if (this.config.useBlockSupportsAsThemeJsonDefaults) {
|
|
200
|
+
const copyableBlockSupports = [];
|
|
201
|
+
for (const { name, supports } of Object.values(blockData)) {
|
|
202
|
+
if (typeof name === 'string' && !!name && typeof supports === 'object' && !!supports && !Array.isArray(supports)) {
|
|
203
|
+
const flagProps = EnhancedBlockJSONPlugin.pickOutFlagPropsFromBlockSupports(supports);
|
|
204
|
+
if (flagProps) {
|
|
205
|
+
copyableBlockSupports.push([name, flagProps]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (copyableBlockSupports.length > 0) {
|
|
210
|
+
const themeJsonBlockSettings = new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)({
|
|
211
|
+
version: 3,
|
|
212
|
+
settings: {
|
|
213
|
+
blocks: Object.fromEntries(copyableBlockSupports)
|
|
214
|
+
}
|
|
215
|
+
}, false, "\t"));
|
|
216
|
+
const theme_json = new expressions_1.Var("theme_json");
|
|
217
|
+
writer.filter('wp_theme_json_data_blocks', writer => {
|
|
218
|
+
const updateCall = new expressions_1.Call(expressions_1.Literal.of("update_with", true), [themeJsonBlockSettings]);
|
|
219
|
+
writer.appendExpr(new expressions_1.InstanceAccess(theme_json, [updateCall]), { return: true });
|
|
220
|
+
}, { functionArgParameters: [theme_json] });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
199
223
|
(0, shared_1.emitPHPWriterAsAsset)(writer, compilation, (0, node_path_1.join)(this.dest.destination, "blockdir-loader.php"));
|
|
200
224
|
}
|
|
201
225
|
else {
|
|
202
226
|
compilation.emitAsset((0, node_path_1.join)(this.dest.destination, "blockdir.config.php"), new webpack_1.sources.RawSource((0, shared_1.makeEmittableConfigPHP)(blockDirConfig, true)));
|
|
203
227
|
}
|
|
204
228
|
}
|
|
229
|
+
// This isn't strictly necessary, but it allows us to trivially eliminate commonly-used block supports flags that aren't used in theme.json
|
|
230
|
+
static IGNORED_THEME_JSON_FLAG_PROPS = ['align', 'alignWide', 'anchor', 'contentRole', 'interactivity', 'listView', 'plaudit'];
|
|
231
|
+
static pickOutFlagPropsFromBlockSupports(supports) {
|
|
232
|
+
const entries = [];
|
|
233
|
+
for (const [key, value] of Object.entries(supports)) {
|
|
234
|
+
if (!key.startsWith("__") && !EnhancedBlockJSONPlugin.IGNORED_THEME_JSON_FLAG_PROPS.includes(key) && value) {
|
|
235
|
+
if (typeof value === 'object') {
|
|
236
|
+
if (!Array.isArray(value)) {
|
|
237
|
+
const v = EnhancedBlockJSONPlugin.pickOutFlagPropsFromBlockSupports(value);
|
|
238
|
+
if (v !== undefined) {
|
|
239
|
+
entries.push([key, v]);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (typeof value === 'boolean') {
|
|
244
|
+
entries.push([key, true]);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
249
|
+
}
|
|
205
250
|
callRegisterFunction(type, writer, baseUriVar, handles) {
|
|
206
251
|
for (const [name, { src, rest }] of handles) {
|
|
207
252
|
writer.call(`wp_register_${type}`, [name, src === false ? false : expressions_1.Op.concat(baseUriVar, src), ...rest]);
|
|
@@ -228,6 +273,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
|
|
|
228
273
|
const pathsNeedRemapping = !this.config.standaloneBlocks && blockJson["plaudit"] !== "simple";
|
|
229
274
|
EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "setup", pathsNeedRemapping, sourceDir, outputDir, compilation, true);
|
|
230
275
|
EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "variations", pathsNeedRemapping, sourceDir, outputDir, compilation, false);
|
|
276
|
+
EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(blockJson);
|
|
231
277
|
const hashForVersion = EnhancedBlockJSONPlugin
|
|
232
278
|
.hashThingForAsset([blockJsonText, ...workableBlockEntrypointsInfo.map(bi => bi.hash)].join("~"));
|
|
233
279
|
if (blockJson["version"]) {
|
|
@@ -474,6 +520,28 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
|
|
|
474
520
|
}
|
|
475
521
|
}
|
|
476
522
|
}
|
|
523
|
+
static knownExperimentalProperties = ['border', 'defaultControls', 'fontFamily', 'fontWeight', 'fontStyle', 'letterSpacing', 'textTransform', 'textDecoration']
|
|
524
|
+
.map(prop => [prop, "__experimental" + prop.substring(0, 1).toUpperCase() + prop.substring(1)]);
|
|
525
|
+
static handleExperimentalBlockSupportsFlags(blockSupports) {
|
|
526
|
+
for (const [key, value] of Object.entries(blockSupports)) {
|
|
527
|
+
if (typeof value === 'object' && !!value && !Array.isArray(value)) {
|
|
528
|
+
EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(value);
|
|
529
|
+
}
|
|
530
|
+
if (!key.startsWith("__experimental")) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
const realKey = key.substring(14, 15).toLowerCase() + key.substring(15);
|
|
534
|
+
if (!(realKey in blockSupports)) {
|
|
535
|
+
blockSupports[realKey] = value;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
// This handles known currently-experimental properties
|
|
539
|
+
for (const [eventualKey, experimentalKey] of EnhancedBlockJSONPlugin.knownExperimentalProperties) {
|
|
540
|
+
if (eventualKey in blockSupports && !(experimentalKey in blockSupports)) {
|
|
541
|
+
blockSupports[experimentalKey] = blockSupports[eventualKey];
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
477
545
|
attachUniquePhase(compilation) {
|
|
478
546
|
compilation.hooks.processAssets.tapPromise({ name: `${this.constructor.name}_CompileLoader`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
|
|
479
547
|
const allSemaphoreData = (await EnhancedBlockJSONPlugin.semaphore.wait())
|
package/dist/shared.d.ts
CHANGED
|
@@ -147,6 +147,7 @@ export type PlauditWordpressWebpackConfig = {
|
|
|
147
147
|
includePostInitFallback?: boolean;
|
|
148
148
|
omitDistDev?: boolean;
|
|
149
149
|
onlyRunPostCSSOnPCSS?: boolean;
|
|
150
|
+
useBlockSupportsAsThemeJsonDefaults?: boolean;
|
|
150
151
|
};
|
|
151
152
|
export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
|
|
152
153
|
readonly standard?: "2026-03-13";
|
|
@@ -173,6 +174,7 @@ export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
|
|
|
173
174
|
readonly includePostInitFallback?: boolean;
|
|
174
175
|
readonly omitDistDev?: boolean;
|
|
175
176
|
onlyRunPostCSSOnPCSS?: boolean;
|
|
177
|
+
readonly useBlockSupportsAsThemeJsonDefaults?: boolean;
|
|
176
178
|
};
|
|
177
179
|
export declare function resolveStandard(standard: PlauditWordpressWebpackConfig['standard']): {
|
|
178
180
|
readonly useWebpackResourceFiltering: true;
|
|
@@ -367,7 +367,7 @@ function commonMakeWebpackConfig(config, commonConfig, webpackConfig, externaliz
|
|
|
367
367
|
if (Array.isArray(externalize) || typeof externalize === 'string') {
|
|
368
368
|
outputLibrary = {
|
|
369
369
|
name: externalize,
|
|
370
|
-
type: "
|
|
370
|
+
type: "window"
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
373
|
else {
|
|
@@ -167,7 +167,7 @@ function injectSupportForInliningSVGsAsStrings(rules) {
|
|
|
167
167
|
}
|
|
168
168
|
function buildVerifiedConfig(config) {
|
|
169
169
|
config = (0, shared_1.applyStandards)(config);
|
|
170
|
-
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false } = config;
|
|
170
|
+
const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false, useBlockSupportsAsThemeJsonDefaults = true, } = config;
|
|
171
171
|
let outputDir = config.outputDir ?? "";
|
|
172
172
|
if (outputDir && useUnifiedLoader && !omitDistDev && (process.env['SERVER_MODE'] ?? 'development') === 'development') {
|
|
173
173
|
outputDir += "-dev";
|
|
@@ -206,7 +206,7 @@ function buildVerifiedConfig(config) {
|
|
|
206
206
|
const cfg = {
|
|
207
207
|
currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
|
|
208
208
|
useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev,
|
|
209
|
-
onlyRunPostCSSOnPCSS
|
|
209
|
+
onlyRunPostCSSOnPCSS, useBlockSupportsAsThemeJsonDefaults
|
|
210
210
|
};
|
|
211
211
|
// Destination -> source map
|
|
212
212
|
const allocatedDestinations = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.93.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/dist",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@plaudit/gutenberg-api-extensions": "^2.97.1",
|
|
32
32
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
33
33
|
"@types/jsdom": "^28.0.3",
|
|
34
|
-
"@types/node": "^25.9.
|
|
34
|
+
"@types/node": "^25.9.5",
|
|
35
35
|
"@types/postcss-functions": "^4.0.4",
|
|
36
36
|
"@types/tapable": "^2.3.0",
|
|
37
37
|
"@types/webpack-sources": "^3.2.3",
|
|
@@ -39,24 +39,24 @@
|
|
|
39
39
|
"webpack-bundle-analyzer": "^4.10.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@plaudit/php-writer": "^1.
|
|
42
|
+
"@plaudit/php-writer": "^1.5.2",
|
|
43
43
|
"@plaudit/postcss-color-function": "^5.1.0",
|
|
44
44
|
"@plaudit/postcss-legacy-shorthand": "^1.0.0",
|
|
45
45
|
"@plaudit/postcss-silent-extend": "^3.0.0",
|
|
46
46
|
"@plaudit/postcss-strip-units": "^3.0.0",
|
|
47
47
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
48
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
49
|
-
"@wordpress/scripts": "^32.
|
|
50
|
-
"autoprefixer": "^10.5.
|
|
48
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.51.0",
|
|
49
|
+
"@wordpress/scripts": "^32.6.0",
|
|
50
|
+
"autoprefixer": "^10.5.3",
|
|
51
51
|
"browser-sync": "^3.0.4",
|
|
52
52
|
"copy-webpack-plugin": "10.2.4",
|
|
53
53
|
"css-minimizer-webpack-plugin": "^6.0.0",
|
|
54
54
|
"cssnano": "^6.1.2",
|
|
55
55
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
56
|
-
"http-proxy-middleware": "^3.0.
|
|
56
|
+
"http-proxy-middleware": "^3.0.7",
|
|
57
57
|
"jsdom": "^29.1.1",
|
|
58
58
|
"json2php": "^0.0.12",
|
|
59
|
-
"postcss": "^8.5.
|
|
59
|
+
"postcss": "^8.5.19",
|
|
60
60
|
"postcss-calc": "^9.0.1",
|
|
61
61
|
"postcss-discard-comments": "^6.0.2",
|
|
62
62
|
"postcss-functions": "^4.0.2",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"postcss-reporter": "^7.1.0",
|
|
71
71
|
"postcss-simple-vars": "^7.0.1",
|
|
72
72
|
"postcss-url": "^10.1.4",
|
|
73
|
-
"webpack": "^5.
|
|
73
|
+
"webpack": "^5.108.4",
|
|
74
74
|
"webpack-remove-empty-scripts": "^1.1.1",
|
|
75
75
|
"xml-formatter": "^3.7.0"
|
|
76
76
|
},
|