Build: Improve how combined assets are generated

Allows to revert changes applied in [54277] - temporary workaround for the failing Test NPM CI check on Windows.

Improvements included:
- generate combined asset files for both production and development
- store in the repository only the production version of the combined assets for packages, we use everything else only in development
- to make unit tests work, ensure that they ignore react fast refresh and use the production version of combined assets that are present in the source code

Props bernhard-reiter, jsnajdr, clorith, wildworks.
Fixes #56615.


Built from https://develop.svn.wordpress.org/trunk@54289


git-svn-id: http://core.svn.wordpress.org/trunk@53848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
gziolo 2022-09-23 08:27:12 +00:00
parent d8525e93c0
commit d963f95253
5 changed files with 9 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-react-refresh-runtime'), 'version' => '794dd7047e2302828128');

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => 'd4cdced5a2afff4a8cc2');

View File

@ -227,6 +227,7 @@ function wp_register_development_scripts( $scripts ) {
if (
! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG
|| empty( $scripts->registered['react'] )
|| defined( 'WP_RUN_CORE_TESTS' )
) {
return;
}
@ -264,8 +265,7 @@ function wp_register_development_scripts( $scripts ) {
* @param WP_Scripts $scripts WP_Scripts object.
*/
function wp_default_packages_scripts( $scripts ) {
$suffix = wp_scripts_get_suffix();
$suffix = defined( 'WP_RUN_CORE_TESTS' ) ? '.min' : wp_scripts_get_suffix();
/*
* Expects multidimensional array like:
*
@ -273,10 +273,10 @@ function wp_default_packages_scripts( $scripts ) {
* 'annotations.js' => array('dependencies' => array(...), 'version' => '...'),
* 'api-fetch.js' => array(...
*/
$assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
$assets = include ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php";
foreach ( $assets as $package_name => $package_data ) {
$basename = basename( $package_name, '.js' );
foreach ( $assets as $file_name => $package_data ) {
$basename = str_replace( $suffix . '.js', '', basename( $file_name ) );
$handle = 'wp-' . $basename;
$path = "/wp-includes/js/dist/{$basename}{$suffix}.js";

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta1-54288';
$wp_version = '6.1-beta1-54289';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.