mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
Build Tools:
- Update the DependencyExtractionWebpackPlugin to 2.3.0 and set it to output a single assets file. - Grunt: copy the assets file to both `SOURCE_DIR` and `BUILD_DIR` as `wp-includes/assets/script-loader-packages.php`. - "Unignore" the `wp-includes/assets` directory. Its content will be committed similarly to `wp-includes/blocks`. - Update `wp_default_packages_scripts()` to use the above file. This also removes the hard-coded lists of packages and packages with translations. Props gziolo, pbearne, johnbillion, isabel_brison, ocean90, azaozz. Fixes #48154. git-svn-id: https://develop.svn.wordpress.org/trunk@47352 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -231,81 +231,23 @@ function wp_get_script_polyfill( &$scripts, $tests ) {
|
||||
function wp_default_packages_scripts( &$scripts ) {
|
||||
$suffix = wp_scripts_get_suffix();
|
||||
|
||||
$packages = array(
|
||||
'a11y',
|
||||
'annotations',
|
||||
'api-fetch',
|
||||
'autop',
|
||||
'blob',
|
||||
'block-directory',
|
||||
'block-editor',
|
||||
'block-library',
|
||||
'block-serialization-default-parser',
|
||||
'blocks',
|
||||
'components',
|
||||
'compose',
|
||||
'core-data',
|
||||
'data',
|
||||
'data-controls',
|
||||
'date',
|
||||
'deprecated',
|
||||
'dom',
|
||||
'dom-ready',
|
||||
'edit-post',
|
||||
'editor',
|
||||
'element',
|
||||
'escape-html',
|
||||
'format-library',
|
||||
'hooks',
|
||||
'html-entities',
|
||||
'i18n',
|
||||
'is-shallow-equal',
|
||||
'keyboard-shortcuts',
|
||||
'keycodes',
|
||||
'list-reusable-blocks',
|
||||
'media-utils',
|
||||
'notices',
|
||||
'nux',
|
||||
'plugins',
|
||||
'primitives',
|
||||
'priority-queue',
|
||||
'redux-routine',
|
||||
'rich-text',
|
||||
'shortcode',
|
||||
'server-side-render',
|
||||
'token-list',
|
||||
'url',
|
||||
'viewport',
|
||||
'warning',
|
||||
'wordcount',
|
||||
);
|
||||
// Expects multidimensional array like:
|
||||
// 'a11y.js' => array('dependencies' => array(...), 'version' => '...'),
|
||||
// 'annotations.js' => array('dependencies' => array(...), 'version' => '...'),
|
||||
// 'api-fetch.js' => array(...
|
||||
$assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
|
||||
|
||||
$package_translations = array(
|
||||
'api-fetch',
|
||||
'blocks',
|
||||
'block-directory',
|
||||
'block-editor',
|
||||
'block-library',
|
||||
'components',
|
||||
'edit-post',
|
||||
'editor',
|
||||
'format-library',
|
||||
'keycodes',
|
||||
'list-reusable-blocks',
|
||||
'nux',
|
||||
);
|
||||
foreach ( $assets as $package_name => $package_data ) {
|
||||
$basename = basename( $package_name, '.js' );
|
||||
$handle = 'wp-' . $basename;
|
||||
$path = "/wp-includes/js/dist/{$basename}{$suffix}.js";
|
||||
|
||||
foreach ( $packages as $package ) {
|
||||
$handle = 'wp-' . $package;
|
||||
$path = "/wp-includes/js/dist/$package$suffix.js";
|
||||
|
||||
if ( ! file_exists( ABSPATH . $path ) ) {
|
||||
continue;
|
||||
if ( ! empty( $package_data['dependencies'] ) ) {
|
||||
$dependencies = $package_data['dependencies'];
|
||||
} else {
|
||||
$dependencies = array();
|
||||
}
|
||||
|
||||
$asset_file = require ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
|
||||
$dependencies = $asset_file['dependencies'];
|
||||
|
||||
// Add dependencies that cannot be detected and generated by build tools.
|
||||
switch ( $handle ) {
|
||||
case 'wp-block-library':
|
||||
@@ -316,9 +258,9 @@ function wp_default_packages_scripts( &$scripts ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$scripts->add( $handle, $path, $dependencies, $asset_file['version'], 1 );
|
||||
$scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
|
||||
|
||||
if ( in_array( $package, $package_translations, true ) ) {
|
||||
if ( in_array( 'wp-i18n', $dependencies, true ) ) {
|
||||
$scripts->set_translations( $handle );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user