Make WordPress Core


Ignore:
Timestamp:
01/05/2026 10:49:26 AM (3 months ago)
Author:
youknowriad
Message:

Build: Update Gutenberg integration to checkout-and-build approach.

This changes WordPress Core's Gutenberg integration from npm packages to checking out and building Gutenberg directly. Instead of syncing individual npm packages, Core now checks out the Gutenberg repository, builds it, and copies the build artifacts.

This enables Core to use Gutenberg's advanced features like route-based navigation, full-page rendering, and the Font Library, while also streamlining future updates.

New commands:

  • npm run gutenberg:checkout - Clones Gutenberg at a specified ref
  • npm run gutenberg:build - Runs Gutenberg's build process
  • npm run gutenberg:copy - Copies and transforms build output to Core
  • npm run gutenberg:integrate - Runs all three steps

Main changes:

  • Removes webpack configs replaced by Gutenberg's build (blocks.js, packages.js, script-modules.js, development.js, vendors.js)
  • Adds Font Library page (/wp-admin/font-library.php)
  • Adds copy scripts to transform Gutenberg plugin paths to Core paths
  • Moves vendor copy step from webpack to Gruntfile

New year, new process. Happy New Year!

Props youknowriad, ellatrix, sirreal, westonruter, desrosj, tellthemachines.
Fixes #64393.

File:
1 edited

Legend:

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

    r61362 r61438  
    151151     *
    152152     *     'interactivity/index.min.js' => array('dependencies' => array(…), 'version' => '…'),
    153      *     'interactivity/debug.min.js' => array('dependencies' => array(…), 'version' => '…'),
    154      *     'interactivity-router/index.min.js' => …
     153     *     'interactivity-router/index.min.js' => array('dependencies' => array(…), 'version' => '…'),
     154     *     'block-library/navigation/view.min.js' => …
    155155     */
    156156    $assets = include ABSPATH . WPINC . "/assets/script-modules-packages{$suffix}.php";
     
    160160         * Build the WordPress Script Module ID from the file name.
    161161         * Prepend `@wordpress/` and remove extensions and `/index` if present:
    162          *   - interactivity/index.min.js  => @wordpress/interactivity
    163          *   - interactivity/debug.min.js  => @wordpress/interactivity/debug
    164          *   - block-library/query/view.js => @wordpress/block-library/query/view
     162         *   - interactivity/index.min.js         => @wordpress/interactivity
     163         *   - interactivity-router/index.min.js  => @wordpress/interactivity-router
     164         *   - block-library/navigation/view.js   => @wordpress/block-library/navigation/view
    165165         */
    166166        $script_module_id = '@wordpress/' . preg_replace( '~(?:/index)?(?:\.min)?\.js$~D', '', $file_name, 1 );
    167 
    168         switch ( $script_module_id ) {
    169             /*
    170              * Interactivity exposes two entrypoints, "/index" and "/debug".
    171              * "/debug" should replace "/index" in development.
    172              */
    173             case '@wordpress/interactivity/debug':
    174                 if ( ! SCRIPT_DEBUG ) {
    175                     continue 2;
    176                 }
    177                 $script_module_id = '@wordpress/interactivity';
    178                 break;
    179             case '@wordpress/interactivity':
    180                 if ( SCRIPT_DEBUG ) {
    181                     continue 2;
    182                 }
    183                 break;
    184         }
    185167
    186168        /*
     
    208190        }
    209191
    210         $path = includes_url( "js/dist/script-modules/{$file_name}" );
    211         wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'], $args );
     192        $path        = includes_url( "js/dist/script-modules/{$file_name}" );
     193        $module_deps = $script_module_data['module_dependencies'] ?? array();
     194        wp_register_script_module( $script_module_id, $path, $module_deps, $script_module_data['version'], $args );
    212195    }
    213196}
     197
     198/**
     199 * Enqueues script modules required by the block editor.
     200 *
     201 * @since 6.9.0
     202 */
     203function wp_enqueue_block_editor_script_modules() {
     204    /*
     205     * Enqueue the LaTeX to MathML loader for the math block editor.
     206     * The loader dynamically imports the main LaTeX to MathML module when needed.
     207     */
     208    wp_enqueue_script_module( '@wordpress/latex-to-mathml/loader' );
     209}
Note: See TracChangeset for help on using the changeset viewer.