Make WordPress Core


Ignore:
Timestamp:
06/23/2021 12:04:47 AM (3 years ago)
Author:
desrosj
Message:

Build/Test Tools: Add the regenerator-runtime script as a dependency to wp-polyfill.

In [51146], the core-js package replaced the deprecated @babel//polyfill one. The core-js package builds wp-polyfill from a configuration provided by @wordpress/babel-preset-default instead of copying a one size fits all polyfill.

That change caused an issue where plugins and themes relying on the regenerator-runtime script being included in the wp-polyfill.js file encountering fatal JavaScript errors.

This adds the regenerator-runtime package to Core and registers it as a dependency for wp-polyfill. While Core does not require regenerator-runtime, it will allow for a smoother transition to using core-js.

This dependency will be removed in a future version of WordPress, so developers are encouraged to add regenerator-runtime as a dependency for any custom script that requires it.

Follow up to [51146].

Props gziolo, herregroen, jeherve, hellofromtonya, peterwilsoncc.
Fixes #52941.

File:
1 edited

Legend:

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

    r51211 r51212  
    8181
    8282    $vendor_scripts = array(
    83         'react'     => array( 'wp-polyfill' ),
    84         'react-dom' => array( 'react' ),
     83        'react'       => array( 'wp-polyfill' ),
     84        'react-dom'   => array( 'react' ),
     85        'regenerator-runtime',
    8586        'moment',
    8687        'lodash',
     
    9293        'wp-polyfill-element-closest',
    9394        'wp-polyfill-object-fit',
    94         'wp-polyfill',
     95        'wp-polyfill' => array( 'regenerator-runtime' ),
    9596    );
    9697
     
    9899        'react'                       => '16.13.1',
    99100        'react-dom'                   => '16.13.1',
     101        'regenerator-runtime'         => '0.13.7',
    100102        'moment'                      => '2.29.1',
    101103        'lodash'                      => '4.17.19',
     
    107109        'wp-polyfill-element-closest' => '2.0.2',
    108110        'wp-polyfill-object-fit'      => '2.3.5',
    109         'wp-polyfill'                 => '7.4.4',
     111        'wp-polyfill'                 => '3.15.0',
    110112    );
    111113
     
    121123        $scripts->add( $handle, $path, $dependencies, $version, 1 );
    122124    }
    123 
    124     $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
    125125
    126126    did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
Note: See TracChangeset for help on using the changeset viewer.