From 896653469aa6efb1909651714af09bc9ff049aaa Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:46:16 -0400 Subject: [PATCH 1/2] Always run `build:gutenberg -- --dev`. --- Gruntfile.js | 8 +++++++- tools/gutenberg/utils.js | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8603635b28fbc..d6812d4024368 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1594,7 +1594,13 @@ module.exports = function(grunt) { args: [ 'tools/gutenberg/download.js' ], opts: { stdio: 'inherit' } }, function( error ) { - done( ! error ); + if ( error ) { + done( false ); + return; + } + grunt.option( 'dev', true ); + grunt.task.run( 'build:gutenberg' ); + done(); } ); } ); diff --git a/tools/gutenberg/utils.js b/tools/gutenberg/utils.js index 2b30befd38735..a3167a3910793 100644 --- a/tools/gutenberg/utils.js +++ b/tools/gutenberg/utils.js @@ -42,13 +42,24 @@ function readGutenbergConfig() { } /** - * Trigger a fresh download of the Gutenberg artifact by spawning download.js. - * Exits the process if the download fails. + * Trigger a fresh download of the Gutenberg artifact by spawning download.js, + * then immediately copy the build to src/ so the files are in place before + * the build process runs copy:files. + * Exits the process if either step fails. */ function downloadGutenberg() { - const result = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } ); - if ( result.status !== 0 ) { - process.exit( result.status ?? 1 ); + const downloadResult = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } ); + if ( downloadResult.status !== 0 ) { + process.exit( downloadResult.status ?? 1 ); + } + + const copyResult = spawnSync( + 'node', + [ path.join( __dirname, 'copy.js' ), '--build-dir=src' ], + { stdio: 'inherit' } + ); + if ( copyResult.status !== 0 ) { + process.exit( copyResult.status ?? 1 ); } } From ec8e4c5a732875292720eae17614989c5f3895fe Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 18 Mar 2026 22:31:37 -0400 Subject: [PATCH 2/2] Ensure `build:gutenberg --dev` always runs. --- Gruntfile.js | 18 +++++++++++++++--- package.json | 2 +- tools/gutenberg/utils.js | 13 ++++--------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 53d165bbb13cb..11f2db7a78ace 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1611,9 +1611,21 @@ module.exports = function(grunt) { done( false ); return; } - grunt.option( 'dev', true ); - grunt.task.run( 'build:gutenberg' ); - done(); + /* + * Build block editor files into the src directory every time assets + * are downloaded. This prevents failures when running from src + * without running `build:dev` after those files were removed from + * version control in https://core.trac.wordpress.org/changeset/61438. + * + * See https://core.trac.wordpress.org/ticket/64393. + */ + grunt.util.spawn( { + grunt: true, + args: [ 'build:gutenberg', '--dev' ], + opts: { stdio: 'inherit' } + }, function( buildError ) { + done( ! buildError ); + } ); } ); } ); diff --git a/package.json b/package.json index 9f67a45262806..3084630a2d726 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "typecheck:php": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan", "gutenberg:copy": "node tools/gutenberg/copy.js", "gutenberg:verify": "node tools/gutenberg/utils.js", - "gutenberg:download": "node tools/gutenberg/download.js", + "gutenberg:download": "node tools/gutenberg/download.js && grunt build:gutenberg --dev", "vendor:copy": "node tools/vendors/copy-vendors.js", "sync-gutenberg-packages": "grunt sync-gutenberg-packages", "postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build" diff --git a/tools/gutenberg/utils.js b/tools/gutenberg/utils.js index a3167a3910793..dc696d5e7bfd7 100644 --- a/tools/gutenberg/utils.js +++ b/tools/gutenberg/utils.js @@ -43,8 +43,7 @@ function readGutenbergConfig() { /** * Trigger a fresh download of the Gutenberg artifact by spawning download.js, - * then immediately copy the build to src/ so the files are in place before - * the build process runs copy:files. + * then run `grunt build:gutenberg --dev` to copy the build to src/. * Exits the process if either step fails. */ function downloadGutenberg() { @@ -53,13 +52,9 @@ function downloadGutenberg() { process.exit( downloadResult.status ?? 1 ); } - const copyResult = spawnSync( - 'node', - [ path.join( __dirname, 'copy.js' ), '--build-dir=src' ], - { stdio: 'inherit' } - ); - if ( copyResult.status !== 0 ) { - process.exit( copyResult.status ?? 1 ); + const buildResult = spawnSync( 'grunt', [ 'build:gutenberg', '--dev' ], { stdio: 'inherit', shell: true } ); + if ( buildResult.status !== 0 ) { + process.exit( buildResult.status ?? 1 ); } }