Make WordPress Core


Ignore:
Timestamp:
09/23/2022 08:25:45 AM (4 years ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r54267 r54289  
    228228        ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG
    229229        || empty( $scripts->registered['react'] )
     230        || defined( 'WP_RUN_CORE_TESTS' )
    230231    ) {
    231232        return;
     
    265266 */
    266267function wp_default_packages_scripts( $scripts ) {
    267     $suffix = wp_scripts_get_suffix();
    268 
     268    $suffix = defined( 'WP_RUN_CORE_TESTS' ) ? '.min' : wp_scripts_get_suffix();
    269269    /*
    270270     * Expects multidimensional array like:
     
    274274     *     'api-fetch.js' => array(...
    275275     */
    276     $assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
    277 
    278     foreach ( $assets as $package_name => $package_data ) {
    279         $basename = basename( $package_name, '.js' );
     276    $assets = include ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php";
     277
     278    foreach ( $assets as $file_name => $package_data ) {
     279        $basename = str_replace( $suffix . '.js', '', basename( $file_name ) );
    280280        $handle   = 'wp-' . $basename;
    281281        $path     = "/wp-includes/js/dist/{$basename}{$suffix}.js";
Note: See TracChangeset for help on using the changeset viewer.