diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index d006c4fe32945..b80853f66429d 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -281,11 +281,11 @@ function wp_default_packages_scripts( $scripts ) { * 'annotations.js' => array('dependencies' => array(...), 'version' => '...'), * 'api-fetch.js' => array(... */ - $assets_file = ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php"; + $assets_file = ABSPATH . WPINC . '/assets/script-loader-packages.php'; $assets = file_exists( $assets_file ) ? include $assets_file : array(); foreach ( $assets as $file_name => $package_data ) { - $basename = str_replace( $suffix . '.js', '', basename( $file_name ) ); + $basename = str_replace( '.js', '', basename( $file_name ) ); $handle = 'wp-' . $basename; $path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; diff --git a/src/wp-includes/script-modules.php b/src/wp-includes/script-modules.php index 411325be3618e..c9afb2614b232 100644 --- a/src/wp-includes/script-modules.php +++ b/src/wp-includes/script-modules.php @@ -149,11 +149,11 @@ function wp_default_script_modules() { /* * Expects multidimensional array like: * - * 'interactivity/index.min.js' => array('dependencies' => array(…), 'version' => '…'), - * 'interactivity-router/index.min.js' => array('dependencies' => array(…), 'version' => '…'), - * 'block-library/navigation/view.min.js' => … + * 'interactivity/index.js' => array('dependencies' => array(…), 'version' => '…'), + * 'interactivity-router/index.js' => array('dependencies' => array(…), 'version' => '…'), + * 'block-library/navigation/view.js' => … */ - $assets_file = ABSPATH . WPINC . "/assets/script-modules-packages{$suffix}.php"; + $assets_file = ABSPATH . WPINC . '/assets/script-modules-packages.php'; $assets = file_exists( $assets_file ) ? include $assets_file : array(); foreach ( $assets as $file_name => $script_module_data ) { @@ -192,8 +192,10 @@ function wp_default_script_modules() { // VIPS files are always minified — the non-minified versions are not // shipped because they are ~10MB of inlined WASM with no debugging value. - if ( str_starts_with( $file_name, 'vips/' ) && ! str_contains( $file_name, '.min.' ) ) { + if ( str_starts_with( $file_name, 'vips/' ) ) { $file_name = str_replace( '.js', '.min.js', $file_name ); + } elseif ( '' !== $suffix ) { + $file_name = str_replace( '.js', $suffix . '.js', $file_name ); } $path = includes_url( "js/dist/script-modules/{$file_name}" ); diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 3a7fc67ad7485..b84ecc55a3449 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -351,14 +351,13 @@ function copyBlockAssets( config ) { } /** - * Generate script-modules-packages.min.php from individual asset files. - * Reads all view.min.asset.php files from modules/block-library and combines them - * into a single PHP file. + * Generate script-modules-packages.php from individual asset files. + * Recursively scans the Gutenberg modules/ directory for *.min.asset.php files + * and combines their contents into a single PHP file. */ function generateScriptModulesPackages() { const modulesDir = path.join( gutenbergBuildDir, 'modules' ); - const assetsMin = {}; - const assetsRegular = {}; + const assets = {}; /** * Recursively process directory to find .asset.php files. @@ -384,16 +383,13 @@ function generateScriptModulesPackages() { const normalizedPath = relativePath .split( path.sep ) .join( '/' ); - const jsPathMin = normalizedPath.replace( - /\.asset\.php$/, - '.js' - ); - const jsPathRegular = jsPathMin.replace( /\.min\.js$/, '.js' ); + const jsPath = normalizedPath + .replace( /\.asset\.php$/, '.js' ) + .replace( /\.min\.js$/, '.js' ); try { const assetData = readReturnedValueFromPHPFile( fullPath ); - assetsMin[ jsPathMin ] = assetData; - assetsRegular[ jsPathRegular ] = assetData; + assets[ jsPath ] = assetData; } catch ( error ) { console.error( ` ⚠️ Error reading ${ relativePath }:`, @@ -406,52 +402,35 @@ function generateScriptModulesPackages() { processDirectory( modulesDir, modulesDir ); - // Generate both minified and non-minified PHP files using json2php. - const phpContentMin = - '