@wordpress/build 0.9.0 → 0.10.1-next.v.202603102151.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/.eslintrc.cjs CHANGED
@@ -4,5 +4,11 @@ module.exports = {
4
4
  rules: {
5
5
  // Console should be allowed in a build tool
6
6
  'no-console': 'off',
7
+ /*
8
+ * These rules are designed for source files processed by esbuild, not for the build script itself,
9
+ * which runs directly in Node.js.
10
+ */
11
+ '@wordpress/no-wp-process-env': 'off',
12
+ '@wordpress/wp-global-usage': 'off',
7
13
  },
8
14
  };
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.10.0-next.0 (2026-03-10)
6
+
7
+ ### Breaking Changes
8
+
9
+ - `@wordpress/boot`, `@wordpress/route`, `@wordpress/theme`, and `@wordpress/private-apis` are no longer bundled. They are now expected to be provided by WordPress Core (7.0+) or the Gutenberg plugin.
10
+
11
+ ### Enhancements
12
+
13
+ - Avoid unexpected results when typecasting `IS_GUTENBERG_PLUGIN` and `IS_WORDPRESS_CORE` values to Booleans ([#75844](https://github.com/WordPress/gutenberg/pull/75844)).
14
+ - Skip PHP transforms during builds when building for WordPress Core ([#75844](https://github.com/WordPress/gutenberg/pull/75844)).
15
+
5
16
  ## 0.9.0 (2026-03-04)
6
17
 
7
18
  ## 0.8.0 (2026-02-18)
package/lib/build.mjs CHANGED
@@ -113,12 +113,27 @@ const HANDLE_PREFIX = WP_PLUGIN_CONFIG.handlePrefix || PACKAGE_NAMESPACE;
113
113
  const EXTERNAL_NAMESPACES = WP_PLUGIN_CONFIG.externalNamespaces || {};
114
114
  const PAGES = WP_PLUGIN_CONFIG.pages || [];
115
115
 
116
+ /**
117
+ * Interprets a configuration value as a boolean, where `"true"` and `"1"`
118
+ * are considered true while all other values are false.
119
+ *
120
+ * @param {string|undefined} value The configuration value to interpret.
121
+ * @return {boolean} Boolean interpretation of the given configuration value.
122
+ */
123
+ const boolConfigVal = ( value ) => {
124
+ return (
125
+ value !== undefined && [ 'true', '1' ].includes( value.toLowerCase() )
126
+ );
127
+ };
128
+
116
129
  const baseDefine = {
117
130
  'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify(
118
- Boolean( process.env.npm_package_config_IS_GUTENBERG_PLUGIN )
131
+ boolConfigVal( process.env.IS_GUTENBERG_PLUGIN ) ||
132
+ boolConfigVal( process.env.npm_package_config_IS_GUTENBERG_PLUGIN )
119
133
  ),
120
134
  'globalThis.IS_WORDPRESS_CORE': JSON.stringify(
121
- Boolean( process.env.npm_package_config_IS_WORDPRESS_CORE )
135
+ boolConfigVal( process.env.IS_WORDPRESS_CORE ) ||
136
+ boolConfigVal( process.env.npm_package_config_IS_WORDPRESS_CORE )
122
137
  ),
123
138
  };
124
139
  const getDefine = ( scriptDebug ) => ( {
@@ -266,8 +281,11 @@ const wasmInlinePlugin = {
266
281
  try {
267
282
  const resolved = require.resolve( args.path );
268
283
  return {
269
- path: resolved,
284
+ path: normalizePath(
285
+ path.relative( ROOT_DIR, resolved )
286
+ ),
270
287
  namespace: 'wasm-inline',
288
+ pluginData: { resolvedPath: resolved },
271
289
  };
272
290
  } catch {
273
291
  // If resolution fails, let other plugins handle it.
@@ -281,7 +299,9 @@ const wasmInlinePlugin = {
281
299
  build.onLoad(
282
300
  { filter: /.*/, namespace: 'wasm-inline' },
283
301
  async ( args ) => {
284
- const wasmBuffer = await readFile( args.path );
302
+ const wasmBuffer = await readFile(
303
+ args.pluginData.resolvedPath
304
+ );
285
305
  const base64 = wasmBuffer.toString( 'base64' );
286
306
  const dataUrl = `data:application/wasm;base64,${ base64 }`;
287
307
 
@@ -315,6 +335,16 @@ function transformPhpContent( content, transforms ) {
315
335
 
316
336
  content = content.toString();
317
337
 
338
+ /*
339
+ * Transforms are used to modify PHP files that are committed to version
340
+ * control in their wordpress-develop state (`wp_` function prefixes, `WP_`
341
+ * class prefixes, etc.). When building for WordPress Core, it's not
342
+ * necessary to perform these steps.
343
+ */
344
+ if ( boolConfigVal( process.env.IS_WORDPRESS_CORE ) ) {
345
+ return content;
346
+ }
347
+
318
348
  if ( prefixFunctions.length ) {
319
349
  content = content.replace(
320
350
  new RegExp( prefixFunctions.join( '|' ), 'g' ),
@@ -1771,11 +1801,23 @@ async function buildAll( baseUrlExpression ) {
1771
1801
  id: page.id,
1772
1802
  init: page.init || [],
1773
1803
  title: page.title || undefined,
1804
+ experimental: page.experimental || false,
1774
1805
  };
1775
1806
  } );
1776
1807
 
1777
- const pageData = normalizedPages.map( ( page ) => {
1778
- const pageRoutes = routes.filter( ( r ) => r.page === page.id );
1808
+ // When building for WordPress Core, exclude experimental pages.
1809
+ const isCoreBuild =
1810
+ boolConfigVal( process.env.IS_WORDPRESS_CORE ) ||
1811
+ boolConfigVal( process.env.npm_package_config_IS_WORDPRESS_CORE );
1812
+ const activePages = isCoreBuild
1813
+ ? normalizedPages.filter( ( page ) => ! page.experimental )
1814
+ : normalizedPages;
1815
+
1816
+ const activePageIds = new Set( activePages.map( ( p ) => p.id ) );
1817
+ const activeRoutes = routes.filter( ( r ) => activePageIds.has( r.page ) );
1818
+
1819
+ const pageData = activePages.map( ( page ) => {
1820
+ const pageRoutes = activeRoutes.filter( ( r ) => r.page === page.id );
1779
1821
  return {
1780
1822
  slug: page.id,
1781
1823
  routes: pageRoutes,
@@ -1784,51 +1826,6 @@ async function buildAll( baseUrlExpression ) {
1784
1826
  };
1785
1827
  } );
1786
1828
 
1787
- // Bundle boot, route, and theme packages from node_modules when pages exist
1788
- if ( pageData.length > 0 ) {
1789
- try {
1790
- const { createRequire } = await import( 'module' );
1791
- const require = createRequire( import.meta.url );
1792
-
1793
- // Resolve the @wordpress packages directory from node_modules
1794
- const bootPackageJson = require.resolve(
1795
- '@wordpress/boot/package.json',
1796
- { paths: [ ROOT_DIR ] }
1797
- );
1798
- const wordpressPackagesDir = path.dirname(
1799
- path.dirname( bootPackageJson )
1800
- );
1801
-
1802
- // Bundle boot, route, theme, and private-apis packages
1803
- const externalPackages = [
1804
- 'boot',
1805
- 'route',
1806
- 'theme',
1807
- 'private-apis',
1808
- ];
1809
- for ( const pkgName of externalPackages ) {
1810
- const result = await bundlePackage( pkgName, {
1811
- sourceDir: wordpressPackagesDir,
1812
- handlePrefix: 'wp',
1813
- scriptGlobal: 'wp',
1814
- packageNamespace: 'wordpress',
1815
- } );
1816
-
1817
- if ( result && result.modules ) {
1818
- modules.push( ...result.modules );
1819
- }
1820
- if ( result && result.scripts ) {
1821
- scripts.push( ...result.scripts );
1822
- }
1823
- }
1824
- } catch ( error ) {
1825
- console.warn(
1826
- '\n⚠️ Warning: Could not bundle WordPress packages for pages:',
1827
- error.message
1828
- );
1829
- }
1830
- }
1831
-
1832
1829
  console.log( '\n📄 Generating PHP registration files...\n' );
1833
1830
  const phpReplacements = await getPhpReplacements(
1834
1831
  ROOT_DIR,
@@ -1840,8 +1837,8 @@ async function buildAll( baseUrlExpression ) {
1840
1837
  generateScriptRegistrationPhp( scripts, phpReplacements ),
1841
1838
  generateStyleRegistrationPhp( styles, phpReplacements ),
1842
1839
  generateConstantsPhp( phpReplacements ),
1843
- generateRoutesRegistry( routes, phpReplacements ),
1844
- generateRoutesPhp( routes, phpReplacements ),
1840
+ generateRoutesRegistry( activeRoutes, phpReplacements ),
1841
+ generateRoutesPhp( activeRoutes, phpReplacements ),
1845
1842
  generatePagesPhp( pageData, phpReplacements ),
1846
1843
  ] );
1847
1844
  console.log( ' ✔ Generated build/build.php' );
@@ -2130,7 +2127,9 @@ async function main() {
2130
2127
  },
2131
2128
  'base-url': {
2132
2129
  type: 'string',
2133
- default: 'plugin_dir_url( __FILE__ )',
2130
+ default: boolConfigVal( process.env.IS_WORDPRESS_CORE )
2131
+ ? "includes_url( 'build/' )"
2132
+ : 'plugin_dir_url( __FILE__ )',
2134
2133
  },
2135
2134
  },
2136
2135
  strict: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/build",
3
- "version": "0.9.0",
3
+ "version": "0.10.1-next.v.202603102151.0+59e17f9ec",
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": "8bfc179b9aed74c0a6dd6e8edf7a49e40e4f87cc"
80
+ "gitHead": "86db21e727d89e8f0dbba9300d2f97fd22b08693"
81
81
  }
@@ -6,44 +6,42 @@
6
6
  * @package {{PREFIX}}
7
7
  */
8
8
 
9
- if ( ! function_exists( '{{PREFIX}}_register_script_modules' ) ) {
10
- /**
11
- * Register all script modules.
12
- */
13
- function {{PREFIX}}_register_script_modules() {
14
- // Load build constants
15
- $build_constants = require __DIR__ . '/constants.php';
16
- $modules_dir = __DIR__ . '/modules';
17
- $modules_file = $modules_dir . '/registry.php';
9
+ /**
10
+ * Register all script modules.
11
+ */
12
+ function {{PREFIX}}_register_script_modules() {
13
+ // Load build constants
14
+ $build_constants = require __DIR__ . '/constants.php';
15
+ $modules_dir = __DIR__ . '/modules';
16
+ $modules_file = $modules_dir . '/registry.php';
18
17
 
19
- if ( ! file_exists( $modules_file ) ) {
20
- return;
21
- }
18
+ if ( ! file_exists( $modules_file ) ) {
19
+ return;
20
+ }
22
21
 
23
- $modules = require $modules_file;
24
- $base_url = $build_constants['build_url'] . 'modules/';
25
- $extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
22
+ $modules = require $modules_file;
23
+ $base_url = $build_constants['build_url'] . 'modules/';
24
+ $extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
26
25
 
27
- foreach ( $modules as $module ) {
28
- $asset_path = $modules_dir . '/' . $module['asset'];
29
- $asset = file_exists( $asset_path ) ? require $asset_path : array();
26
+ foreach ( $modules as $module ) {
27
+ $asset_path = $modules_dir . '/' . $module['asset'];
28
+ $asset = file_exists( $asset_path ) ? require $asset_path : array();
30
29
 
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'] );
30
+ // Deregister first to override any previously registered version
31
+ // (e.g., Core's default modules when running as a plugin).
32
+ wp_deregister_script_module( $module['id'] );
34
33
 
35
- wp_register_script_module(
36
- $module['id'],
37
- $base_url . $module['path'] . $extension,
38
- $asset['module_dependencies'] ?? array(),
39
- $asset['version'] ?? false,
40
- array(
41
- 'fetchpriority' => 'low',
42
- 'in_footer' => true,
43
- )
44
- );
45
- }
34
+ wp_register_script_module(
35
+ $module['id'],
36
+ $base_url . $module['path'] . $extension,
37
+ $asset['module_dependencies'] ?? array(),
38
+ $asset['version'] ?? false,
39
+ array(
40
+ 'fetchpriority' => 'low',
41
+ 'in_footer' => true,
42
+ )
43
+ );
46
44
  }
47
-
48
- add_action( 'wp_default_scripts', '{{PREFIX}}_register_script_modules' );
49
45
  }
46
+
47
+ add_action( 'wp_default_scripts', '{{PREFIX}}_register_script_modules' );