Make WordPress Core

Changeset 47352


Ignore:
Timestamp:
02/24/2020 09:20:49 PM (5 years ago)
Author:
azaozz
Message:

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.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/.gitignore

    r47035 r47352  
    2525/src/wp-admin/css/colors/*/*.css
    2626/src/wp-admin/js
    27 /src/wp-includes/assets
    2827/src/wp-includes/js
    2928/src/wp-includes/css/dist
  • trunk/Gruntfile.js

    r47348 r47352  
    118118            ],
    119119            'webpack-assets': [
    120                 WORKING_DIR + 'wp-includes/js/**/*.asset.php'
     120                WORKING_DIR + 'wp-includes/js/dist/assets.php'
    121121            ],
    122122            dynamic: {
     
    357357            },
    358358            'webpack-assets': {
    359                 expand: true,
    360                 cwd: WORKING_DIR + 'wp-includes/js/',
    361                 src: 'dist/*.asset.php',
    362                 dest: WORKING_DIR + 'wp-includes/assets/'
     359                files: [
     360                    {
     361                        src: WORKING_DIR + 'wp-includes/js/dist/assets.php',
     362                        dest: SOURCE_DIR + 'wp-includes/assets/script-loader-packages.php'
     363                    },
     364                    {
     365                        src:  WORKING_DIR + 'wp-includes/js/dist/assets.php',
     366                        dest: BUILD_DIR + 'wp-includes/assets/script-loader-packages.php'
     367                    }
     368                ]
    363369            },
    364370            version: {
  • trunk/package-lock.json

    r47302 r47352  
    25262526        },
    25272527        "@wordpress/dependency-extraction-webpack-plugin": {
    2528             "version": "2.2.0",
    2529             "resolved": "https://registry.npmjs.org/@wordpress/dependency-extraction-webpack-plugin/-/dependency-extraction-webpack-plugin-2.2.0.tgz",
    2530             "integrity": "sha512-74zJPfSohTfcNtNG/Y0VmE/ow1sG6wCEl7A7xN3VdhMRFUOfpfGV2XifBA9UjDoxY/IAbf80WDqiuA7MzcDMKw==",
     2528            "version": "2.3.0",
     2529            "resolved": "https://registry.npmjs.org/@wordpress/dependency-extraction-webpack-plugin/-/dependency-extraction-webpack-plugin-2.3.0.tgz",
     2530            "integrity": "sha512-FwEN0PuFr3Q5IdDLgerkIspiHkePNbzem71R3RlUevaSmnw+iH9/0Jzg4uIQ8KCMBpbrn1gAmhgdaTgTDn3EfQ==",
    25312531            "dev": true,
    25322532            "requires": {
  • trunk/package.json

    r47302 r47352  
    2727    "devDependencies": {
    2828        "@wordpress/custom-templated-path-webpack-plugin": "1.6.0",
    29         "@wordpress/dependency-extraction-webpack-plugin": "2.2.0",
     29        "@wordpress/dependency-extraction-webpack-plugin": "2.3.0",
    3030        "@wordpress/e2e-test-utils": "4.3.0",
    3131        "@wordpress/library-export-default-webpack-plugin": "1.6.0",
  • trunk/src/wp-includes

    • Property svn:ignore
      •  

        old new  
        1 assets
         1
        22js
  • trunk/src/wp-includes/script-loader.php

    r47259 r47352  
    232232    $suffix = wp_scripts_get_suffix();
    233233
    234     $packages = array(
    235         'a11y',
    236         'annotations',
    237         'api-fetch',
    238         'autop',
    239         'blob',
    240         'block-directory',
    241         'block-editor',
    242         'block-library',
    243         'block-serialization-default-parser',
    244         'blocks',
    245         'components',
    246         'compose',
    247         'core-data',
    248         'data',
    249         'data-controls',
    250         'date',
    251         'deprecated',
    252         'dom',
    253         'dom-ready',
    254         'edit-post',
    255         'editor',
    256         'element',
    257         'escape-html',
    258         'format-library',
    259         'hooks',
    260         'html-entities',
    261         'i18n',
    262         'is-shallow-equal',
    263         'keyboard-shortcuts',
    264         'keycodes',
    265         'list-reusable-blocks',
    266         'media-utils',
    267         'notices',
    268         'nux',
    269         'plugins',
    270         'primitives',
    271         'priority-queue',
    272         'redux-routine',
    273         'rich-text',
    274         'shortcode',
    275         'server-side-render',
    276         'token-list',
    277         'url',
    278         'viewport',
    279         'warning',
    280         'wordcount',
    281     );
    282 
    283     $package_translations = array(
    284         'api-fetch',
    285         'blocks',
    286         'block-directory',
    287         'block-editor',
    288         'block-library',
    289         'components',
    290         'edit-post',
    291         'editor',
    292         'format-library',
    293         'keycodes',
    294         'list-reusable-blocks',
    295         'nux',
    296     );
    297 
    298     foreach ( $packages as $package ) {
    299         $handle = 'wp-' . $package;
    300         $path   = "/wp-includes/js/dist/$package$suffix.js";
    301 
    302         if ( ! file_exists( ABSPATH . $path ) ) {
    303             continue;
    304         }
    305 
    306         $asset_file   = require ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
    307         $dependencies = $asset_file['dependencies'];
     234    // Expects multidimensional array like:
     235    //  'a11y.js' => array('dependencies' => array(...), 'version' => '...'),
     236    //  'annotations.js' => array('dependencies' => array(...), 'version' => '...'),
     237    //  'api-fetch.js' => array(...
     238    $assets = include ABSPATH . WPINC . '/assets/script-loader-packages.php';
     239
     240    foreach ( $assets as $package_name => $package_data ) {
     241        $basename = basename( $package_name, '.js' );
     242        $handle   = 'wp-' . $basename;
     243        $path     = "/wp-includes/js/dist/{$basename}{$suffix}.js";
     244
     245        if ( ! empty( $package_data['dependencies'] ) ) {
     246            $dependencies = $package_data['dependencies'];
     247        } else {
     248            $dependencies = array();
     249        }
    308250
    309251        // Add dependencies that cannot be detected and generated by build tools.
     
    317259        }
    318260
    319         $scripts->add( $handle, $path, $dependencies, $asset_file['version'], 1 );
    320 
    321         if ( in_array( $package, $package_translations, true ) ) {
     261        $scripts->add( $handle, $path, $dependencies, $package_data['version'], 1 );
     262
     263        if ( in_array( 'wp-i18n', $dependencies, true ) ) {
    322264            $scripts->set_translations( $handle );
    323265        }
  • trunk/tools/webpack/packages.js

    r47301 r47352  
    247247            new DependencyExtractionPlugin( {
    248248                injectPolyfill: true,
     249                combineAssets: true,
    249250            } ),
    250251            new CopyWebpackPlugin(
Note: See TracChangeset for help on using the changeset viewer.