From d0406ad2388681e5b2b0080709304974d8434b11 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:23:11 -0400 Subject: [PATCH] Remove dead code from `copy.js`. This removes several groups from `COPY_CONFIG` that were moved to Grunt tasks for consistency. The `copyDirectory()` function is also being removed because it's never called. --- Gruntfile.js | 2 +- tools/gutenberg/copy.js | 123 ---------------------------------------- 2 files changed, 1 insertion(+), 124 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 821046a4c86c6..4aded0a659c00 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2064,7 +2064,7 @@ module.exports = function(grunt) { grunt.registerTask( 'build', function() { var done = this.async(); - + grunt.util.spawn( { grunt: true, args: [ 'clean', '--dev' ], diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 3a7fc67ad7485..5abb85a32ff09 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -38,13 +38,6 @@ const wpIncludesDir = path.join( rootDir, buildTarget, 'wp-includes' ); * Defines what to copy from Gutenberg build and where it goes in Core. */ const COPY_CONFIG = { - // PHP infrastructure files (to wp-includes/build/). - phpInfrastructure: { - destination: 'build', - files: [ 'routes.php', 'pages.php', 'constants.php' ], - directories: [ 'pages', 'routes' ], - }, - // JavaScript packages (to wp-includes/js/dist/). scripts: { source: 'scripts', @@ -56,18 +49,6 @@ const COPY_CONFIG = { }, }, - // Script modules (to wp-includes/js/dist/script-modules/). - modules: { - source: 'modules', - destination: 'js/dist/script-modules', - }, - - // Styles (to wp-includes/css/dist/). - styles: { - source: 'styles', - destination: 'css/dist', - }, - /* * Blocks (to wp-includes/blocks/). * Unified configuration for all block types. @@ -91,27 +72,6 @@ const COPY_CONFIG = { }, ], }, - - // Theme JSON files (from Gutenberg lib directory). - themeJson: { - files: [ - { from: 'theme.json', to: 'theme.json' }, - { from: 'theme-i18n.json', to: 'theme-i18n.json' }, - ], - transform: true, - }, - - // Specific files to copy to wp-includes/$destination. - wpIncludes: [ - { - files: [ 'packages/icons/src/manifest.php' ], - destination: 'icons', - }, - { - files: [ 'packages/icons/src/library/*.svg' ], - destination: 'icons/library', - }, - ], }; /** @@ -170,83 +130,6 @@ function isExperimentalBlock( blockJsonPath ) { } } -/** - * Recursively copy directory. - * - * @param {string} src - Source directory. - * @param {string} dest - Destination directory. - * @param {Function} transform - Optional transform function for file contents. - * @param {Object} options - Optional configuration. - * @param {boolean} options.excludePHP - Skip PHP files. - * @param {boolean} options.excludeExperimental - Skip experimental blocks. - */ -function copyDirectory( src, dest, transform = null, options = {} ) { - if ( ! fs.existsSync( src ) ) { - return; - } - - fs.mkdirSync( dest, { recursive: true } ); - - const entries = fs.readdirSync( src, { withFileTypes: true } ); - - for ( const entry of entries ) { - const srcPath = path.join( src, entry.name ); - const destPath = path.join( dest, entry.name ); - - if ( entry.isDirectory() ) { - // Check if this directory is an experimental block. - if ( options.excludeExperimental ) { - const blockJsonPath = path.join( srcPath, 'block.json' ); - if ( isExperimentalBlock( blockJsonPath ) ) { - continue; - } - } - - copyDirectory( srcPath, destPath, transform, options ); - } else { - // Skip source map files (.map) — these are not useful in Core, - // and the sourceMappingURL references are already stripped from JS files. - if ( /\.map$/.test( entry.name ) ) { - continue; - } - - // Skip non-minified VIPS files — they are ~10MB of inlined WASM, - // with no debugging value over the minified versions. - if ( - srcPath.includes( '/vips/' ) && - /(?