@wordpress/build 0.8.1-next.v.202602241322.0 → 0.9.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
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.9.0 (2026-03-04)
6
+
5
7
  ## 0.8.0 (2026-02-18)
6
8
 
7
9
  ## 0.7.0 (2026-01-29)
package/lib/build.mjs CHANGED
@@ -21,6 +21,26 @@ import babel from 'esbuild-plugin-babel';
21
21
  import { camelCase } from 'change-case';
22
22
  import { NodePackageImporter } from 'sass-embedded';
23
23
 
24
+ // Optional dependency: @wordpress/theme provides plugins that inject fallback
25
+ // values for design system tokens. Fails gracefully when the package is not
26
+ // installed (it is an optional peerDependency).
27
+ let dsTokenFallbacks;
28
+ let dsTokenFallbacksJs;
29
+ try {
30
+ const { default: postcssPlugin } = await import(
31
+ // eslint-disable-next-line import/no-unresolved
32
+ '@wordpress/theme/postcss-plugins/postcss-ds-token-fallbacks'
33
+ );
34
+ const { default: esbuildPlugin } = await import(
35
+ // eslint-disable-next-line import/no-unresolved
36
+ '@wordpress/theme/esbuild-plugins/esbuild-ds-token-fallbacks'
37
+ );
38
+ dsTokenFallbacks = postcssPlugin;
39
+ dsTokenFallbacksJs = esbuildPlugin;
40
+ } catch {
41
+ // @wordpress/theme is optional; skip token fallbacks if not available.
42
+ }
43
+
24
44
  /**
25
45
  * Internal dependencies
26
46
  */
@@ -150,8 +170,9 @@ function compileInlineStyle( { cssModules = false, minify = true } = {} ) {
150
170
 
151
171
  let moduleExports = null;
152
172
 
153
- // Transform the code: CSS modules and minification.
173
+ // Transform the code: token fallbacks, CSS modules and minification.
154
174
  const plugins = [
175
+ dsTokenFallbacks,
155
176
  cssModules &&
156
177
  postcssModules( {
157
178
  generateScopedName: '[contenthash]__[local]',
@@ -173,7 +194,7 @@ function compileInlineStyle( { cssModules = false, minify = true } = {} ) {
173
194
  map: false,
174
195
  } );
175
196
 
176
- let cssModule = `if (typeof document !== 'undefined' && !document.head.querySelector("style[data-wp-hash='${ hash }']")) {
197
+ let cssModule = `if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector("style[data-wp-hash='${ hash }']")) {
177
198
  const style = document.createElement("style");
178
199
  style.setAttribute("data-wp-hash", "${ hash }");
179
200
  style.appendChild(document.createTextNode(${ JSON.stringify( css ) }));
@@ -207,6 +228,7 @@ function createStyleBundlingPlugins( workingDir ) {
207
228
  // Handle CSS modules (.module.css and .module.scss)
208
229
  sassPlugin( {
209
230
  embedded: true,
231
+ sourceMap: false,
210
232
  filter: /\.module\.(css|scss)$/,
211
233
  transform: compileInlineStyle( { cssModules: true } ),
212
234
  type: inlineStyle,
@@ -216,6 +238,7 @@ function createStyleBundlingPlugins( workingDir ) {
216
238
  // Note: .module.css and .module.scss already handled by plugin above
217
239
  sassPlugin( {
218
240
  embedded: true,
241
+ sourceMap: false,
219
242
  filter: /\.(css|scss)$/,
220
243
  transform: compileInlineStyle(),
221
244
  type: inlineStyle,
@@ -1251,6 +1274,11 @@ async function transpilePackage( packageName ) {
1251
1274
  },
1252
1275
  };
1253
1276
  const plugins = [
1277
+ // Note: dsTokenFallbacksJs and emotionPlugin both use esbuild's onLoad
1278
+ // hook, which is non-composable — the first to return contents wins. If a
1279
+ // file contains --wpds-* tokens, the Emotion transform will be skipped.
1280
+ // Avoid using design tokens in Emotion styles until Emotion is removed.
1281
+ dsTokenFallbacksJs,
1254
1282
  needsEmotionPlugin && emotionPlugin,
1255
1283
  wasmInlinePlugin,
1256
1284
  externalizeAllExceptCssPlugin,
@@ -1408,12 +1436,13 @@ async function compileStyles( packageName ) {
1408
1436
  embedded: true,
1409
1437
  ...getSassOptions( packageDir ),
1410
1438
  async transform( source ) {
1411
- // Process with autoprefixer for LTR version
1412
- const ltrResult = await postcss( [
1413
- autoprefixer( { grid: true } ),
1414
- ] ).process( source, { from: undefined } );
1439
+ const ltrResult = await postcss(
1440
+ [
1441
+ dsTokenFallbacks,
1442
+ autoprefixer( { grid: true } ),
1443
+ ].filter( Boolean )
1444
+ ).process( source, { from: undefined } );
1415
1445
 
1416
- // Process with rtlcss for RTL version
1417
1446
  const rtlResult = await postcss( [
1418
1447
  rtlcss(),
1419
1448
  ] ).process( ltrResult.css, { from: undefined } );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/build",
3
- "version": "0.8.1-next.v.202602241322.0+bce7cff88",
3
+ "version": "0.9.0",
4
4
  "description": "Build tool for WordPress plugins.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "943dde7f0b600ce238726c36284bc9f70ce0ffa4"
80
+ "gitHead": "8bfc179b9aed74c0a6dd6e8edf7a49e40e4f87cc"
81
81
  }
@@ -28,6 +28,10 @@ if ( ! function_exists( '{{PREFIX}}_register_script_modules' ) ) {
28
28
  $asset_path = $modules_dir . '/' . $module['asset'];
29
29
  $asset = file_exists( $asset_path ) ? require $asset_path : array();
30
30
 
31
+ // Deregister first to override any previously registered version
32
+ // (e.g., Core's default modules when running as a plugin).
33
+ wp_deregister_script_module( $module['id'] );
34
+
31
35
  wp_register_script_module(
32
36
  $module['id'],
33
37
  $base_url . $module['path'] . $extension,