@wordpress/build 0.27.0 → 0.29.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 +35 -0
- package/README.md +46 -9
- package/lib/build.mjs +350 -378
- package/lib/copy-files.mjs +165 -0
- package/lib/package-utils.mjs +14 -0
- package/lib/style-dependencies.mjs +69 -0
- package/lib/translator-comments-plugin.mjs +347 -0
- package/package.json +10 -11
- package/templates/build.php.template +4 -0
- package/templates/constants.php.template +7 -2
- package/templates/module-registration.php.template +5 -2
- package/templates/module-registry.php.template +4 -0
- package/templates/page-wp-admin.php.template +65 -52
- package/templates/page.php.template +25 -19
- package/templates/pages.php.template +4 -0
- package/templates/route-registry.php.template +4 -0
- package/templates/routes-registration.php.template +12 -2
- package/templates/script-registration.php.template +9 -1
- package/templates/script-registry.php.template +4 -0
- package/templates/style-registration.php.template +9 -1
- package/templates/style-registry.php.template +4 -0
- package/templates/widget-registration.php.template +8 -1
- package/templates/widget-registry.php.template +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.29.0 (2026-12-02)
|
|
6
|
+
|
|
7
|
+
### New Features
|
|
8
|
+
|
|
9
|
+
- Add a `--no-script-debug` flag that skips generating the unminified debug assets, for plugins that would rather not ship them. The generated registration code loads the minified files even when `SCRIPT_DEBUG` is enabled if the build has no unminified files ([#75396](https://github.com/WordPress/gutenberg/pull/75396)).
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- Keep `translators:` comments next to their `__()`, `_x()`, `_n()` and `_nx()` calls in the transpiled and unminified output, so `wp i18n make-pot` extracts them from the built files ([#87189](https://github.com/WordPress/gutenberg/pull/87189)).
|
|
14
|
+
|
|
15
|
+
### Internal
|
|
16
|
+
|
|
17
|
+
- Remove the unused `moment-timezone` dependency. The `moment-timezone` alias resolves the pre-built bundle from the package that imports it, never from `wp-build` ([#87538](https://github.com/WordPress/gutenberg/pull/87538)).
|
|
18
|
+
- The generated registration PHP now picks the `SCRIPT_DEBUG` file extension with an `if` that also checks the new `has_debug_assets` key of `build/constants.php`, in every build. Tools that post-process the generated PHP may need updating; read `has_debug_assets` instead of matching the template code ([#75396](https://github.com/WordPress/gutenberg/pull/75396)).
|
|
19
|
+
- Update `@types/node` development dependency to 24.19.2 ([#87251](https://github.com/WordPress/gutenberg/pull/87251)).
|
|
20
|
+
- Update `vitest` development dependency to 5.1.1 ([#87254](https://github.com/WordPress/gutenberg/pull/87254)).
|
|
21
|
+
|
|
22
|
+
## 0.28.0 (2026-11-18)
|
|
23
|
+
|
|
24
|
+
### Enhancements
|
|
25
|
+
|
|
26
|
+
- In watch mode, copy a changed PHP file from `wpCopyFiles` to the build on its own instead of rebuilding its whole package, so the change reaches the build in milliseconds rather than seconds. Adding or removing a PHP file still rebuilds the package ([#86271](https://github.com/WordPress/gutenberg/pull/86271)).
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
- Exit the generated PHP files when they are accessed directly, print the inline styles and scripts of generated pages through the WordPress enqueue functions, and escape the message shown when a user cannot access a page. Plugins shipping the build now pass the WordPress.org Plugin Directory review and Plugin Check ([#86699](https://github.com/WordPress/gutenberg/pull/86699)).
|
|
31
|
+
- Require PostCSS `^8.5.33` for CSS parser fixes and source-map file-loading protections ([#86899](https://github.com/WordPress/gutenberg/pull/86899)).
|
|
32
|
+
- Let a full-page screen show the admin bar again. The page template's rule that hides it now loads after the page's own styles, so it has zero specificity to keep it overridable ([#86992](https://github.com/WordPress/gutenberg/pull/86992)).
|
|
33
|
+
- Load a `wp-admin` page's scripts and styles only on its own screen, not on a Core screen whose screen ID matches the page slug. The `dashboard` page no longer hides the content of the Core Dashboard (`index.php`) ([#86995](https://github.com/WordPress/gutenberg/pull/86995)).
|
|
34
|
+
|
|
35
|
+
### Internal
|
|
36
|
+
|
|
37
|
+
- Widen the `@wordpress/theme` peer dependency range to include 5.x ([#86720](https://github.com/WordPress/gutenberg/pull/86720)).
|
|
38
|
+
- Update the Vitest development dependency to 5.1.0 ([#86509](https://github.com/WordPress/gutenberg/pull/86509)).
|
|
39
|
+
|
|
5
40
|
## 0.27.0 (2026-11-04)
|
|
6
41
|
|
|
7
42
|
### Enhancements
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Build tool for WordPress plugins.
|
|
|
9
9
|
- **Transpilation**: Converts TypeScript/JSX source code to both CommonJS (`build/`) and ESM (`build-module/`) formats using Rolldown
|
|
10
10
|
- **Style Compilation**: Processes SCSS files and CSS modules, generating LTR and RTL versions
|
|
11
11
|
- **Bundling**: Creates browser-ready bundles for WordPress scripts and modules
|
|
12
|
+
- **Translator Comments**: Keeps `translators:` comments next to the `__()`, `_x()`, `_n()` and `_nx()` calls they describe in the transpiled and unminified output, so `wp i18n make-pot` can extract them from the built files
|
|
12
13
|
- **PHP Generation**: Automatically generates PHP registration files for scripts, modules, and styles
|
|
13
14
|
- **Watch Mode**: Incremental rebuilds during development
|
|
14
15
|
|
|
@@ -52,6 +53,20 @@ or via npm script:
|
|
|
52
53
|
}
|
|
53
54
|
```
|
|
54
55
|
|
|
56
|
+
### Skipping Debug Assets
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
wp-build --no-script-debug
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Builds only the minified `.min.js` and `.min.css` files, leaving out the non-minified copies used when `SCRIPT_DEBUG` is enabled. The generated registration code then loads the minified files even with `SCRIPT_DEBUG` on. Code that registers files from the build directory by hand should check the `has_debug_assets` key of the array that `build/constants.php` returns, the same way. The flag is ignored in watch mode.
|
|
63
|
+
|
|
64
|
+
`wp-build` does not empty the build directory, so remove it first to drop non-minified files left by an earlier build.
|
|
65
|
+
|
|
66
|
+
Without the non-minified files, `wp i18n make-pot` (which WordPress.org also runs to import plugin strings) skips `*.min.js` and reads JavaScript strings only from the `*.min.js.map` source maps. Ship those maps with the plugin, and do not exclude `*.map` in `.distignore`, or the plugin's JavaScript strings cannot be translated. This works because the maps embed the JavaScript that `wp-build` compiles each package to; `make-pot` cannot parse TypeScript, so it finds no strings in a source map that embeds TypeScript sources. Routes and widgets are built without source maps, so their strings are not extracted from a `--no-script-debug` build.
|
|
67
|
+
|
|
68
|
+
Gutenberg's own build does not support the flag yet. Its `lib/client-assets.php` registers some stylesheets by hand without checking `has_debug_assets`, so a Gutenberg build made with `--no-script-debug` requests missing non-minified files when `SCRIPT_DEBUG` is enabled.
|
|
69
|
+
|
|
55
70
|
### Build Concurrency
|
|
56
71
|
|
|
57
72
|
By default, `wp-build` limits concurrent Rolldown build jobs to half of the available CPU parallelism, rounded up. This prevents large projects from starting every package, route, and widget bundle at once.
|
|
@@ -137,20 +152,37 @@ Custom SCSS entry point patterns:
|
|
|
137
152
|
|
|
138
153
|
### `wpCopyFiles`
|
|
139
154
|
|
|
140
|
-
Files to copy with optional PHP transformations:
|
|
155
|
+
Files to copy to `build/scripts/{package}/`, with optional PHP transformations:
|
|
141
156
|
|
|
142
157
|
```json
|
|
143
158
|
{
|
|
144
|
-
"wpCopyFiles":
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
159
|
+
"wpCopyFiles": {
|
|
160
|
+
"files": [ "src/**/*.php", "src/*/block.json" ],
|
|
161
|
+
"transforms": {
|
|
162
|
+
"php": {
|
|
163
|
+
"functionPrefix": "gutenberg_",
|
|
164
|
+
"classSuffix": "_Gutenberg",
|
|
165
|
+
"prefixFunctions": [ "wp_apply_colors_support" ],
|
|
166
|
+
"suffixClasses": [ "WP_Navigation_Block_Renderer" ],
|
|
167
|
+
"addActionPriority": 20,
|
|
168
|
+
"flattenIndexFiles": true
|
|
169
|
+
}
|
|
149
170
|
}
|
|
150
|
-
|
|
171
|
+
}
|
|
151
172
|
}
|
|
152
173
|
```
|
|
153
174
|
|
|
175
|
+
`files` are glob patterns relative to the package, and each file keeps its path relative to `src/`. The PHP transforms apply only to `.php` files, and are skipped when `IS_WORDPRESS_CORE` is set:
|
|
176
|
+
|
|
177
|
+
- `functionPrefix`: Prefix for the functions a file defines, replacing a `wp_` prefix, and for their uses.
|
|
178
|
+
- `prefixFunctions`: Other functions to prefix with `functionPrefix`.
|
|
179
|
+
- `classSuffix` and `suffixClasses`: Suffix to add to the given classes.
|
|
180
|
+
- `addActionPriority`: Priority to add to the `init` action registering a block.
|
|
181
|
+
- `filenameSuffix`: Suffix for the copied file's name, e.g. `-gutenberg` for `class-wp-style-engine-gutenberg.php`.
|
|
182
|
+
- `flattenIndexFiles`: Copy `{name}/index.php` to `{name}.php`.
|
|
183
|
+
|
|
184
|
+
In watch mode, a change to one of these PHP files copies only that file to the build, without rebuilding the package. Adding or removing a file rebuilds the package, but the build's copy of a removed file is not deleted.
|
|
185
|
+
|
|
154
186
|
### `wpWorkers`
|
|
155
187
|
|
|
156
188
|
Worker bundle definitions for packages that need self-contained Web Worker files.
|
|
@@ -480,7 +512,7 @@ routes/
|
|
|
480
512
|
stage.tsx # Main content component
|
|
481
513
|
inspector.tsx # Optional sidebar component
|
|
482
514
|
canvas.tsx # Optional custom canvas component
|
|
483
|
-
route.tsx # Optional lifecycle hooks (beforeLoad, loader, canvas)
|
|
515
|
+
route.tsx # Optional lifecycle hooks (beforeLoad, loader, canvas, title)
|
|
484
516
|
```
|
|
485
517
|
|
|
486
518
|
### Route Configuration
|
|
@@ -550,6 +582,7 @@ Export a `route` object with optional hooks. Each hook receives `{ params, searc
|
|
|
550
582
|
- `CanvasData` (`{ postType, postId, isPreview?, editLink? }`) → default WordPress editor canvas
|
|
551
583
|
- `null` → custom `canvas.tsx` component (if provided)
|
|
552
584
|
- `undefined` or omitted → no canvas
|
|
585
|
+
- **`title`** — Runs in parallel with `loader`. Returns the page's title as a string, or a promise of a string. After each navigation within the application, the title is announced to screen readers and used to update the document title. Every route should define it: without it, screen reader users do not hear that the page changed, and the browser tab keeps the title of the previous page.
|
|
553
586
|
|
|
554
587
|
```tsx
|
|
555
588
|
export const route = {
|
|
@@ -574,6 +607,10 @@ export const route = {
|
|
|
574
607
|
// Return undefined to show no canvas
|
|
575
608
|
// return undefined;
|
|
576
609
|
},
|
|
610
|
+
title: ( { params, search } ) => {
|
|
611
|
+
// Return the page title
|
|
612
|
+
return __( 'Settings', 'my-plugin' );
|
|
613
|
+
},
|
|
577
614
|
};
|
|
578
615
|
```
|
|
579
616
|
|
|
@@ -726,7 +763,7 @@ The generated `widgets.php` registers each widget's entries as script modules vi
|
|
|
726
763
|
{handlePrefix}/widgets/{widget-dir-name}/widget
|
|
727
764
|
```
|
|
728
765
|
|
|
729
|
-
Registration is hooked into the `init` action. The `SCRIPT_DEBUG` constant controls whether minified (`.min.js`) or non-minified (`.js`) files are loaded.
|
|
766
|
+
Registration is hooked into the `init` action. The `SCRIPT_DEBUG` constant controls whether minified (`.min.js`) or non-minified (`.js`) files are loaded. Builds made with `--no-script-debug` do not include the non-minified files, so they always load the minified ones.
|
|
730
767
|
|
|
731
768
|
### Watch Mode
|
|
732
769
|
|