Make WordPress Core


Ignore:
Timestamp:
09/24/2024 07:33:55 AM (2 years ago)
Author:
gziolo
Message:

Build: Prepare for more Script Modules

This is a companion to ​https://github.com/WordPress/gutenberg/pull/65460 that requires syncing in WordPress Core. Namely, the block-library changes require registration with their updated script module IDs so that the blocks continue to work correctly.

They key improvement is script modules registration is handled in one central place, and a combined asset file is used to improve the performance by avoiding multiple disk operations for every individual file.

Props jonsurrell, gziolo, wildworks, noisysocks.
See #60647, #59462.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php

    r58825 r59083  
    282282         * Registers the `@wordpress/interactivity` script modules.
    283283         *
     284         * @deprecated 6.7.0 Script Modules registration is handled by {@see wp_default_script_modules()}.
     285         *
    284286         * @since 6.5.0
    285287         */
    286288        public function register_script_modules() {
    287                 $suffix = wp_scripts_get_suffix();
    288 
    289                 wp_register_script_module(
    290                         '@wordpress/interactivity',
    291                         includes_url( "js/dist/interactivity$suffix.js" )
    292                 );
    293 
    294                 wp_register_script_module(
    295                         '@wordpress/interactivity-router',
    296                         includes_url( "js/dist/interactivity-router$suffix.js" ),
    297                         array( '@wordpress/interactivity' )
    298                 );
     289                _deprecated_function( __METHOD__, '6.7.0', 'wp_default_script_modules' );
    299290        }
    300291
    … …  
    303294         *
    304295         * @since 6.5.0
    305          * @since 6.7.0 Use the {@see "script_module_data_{$module_id}"} filter to pass client-side data.
    306296         */
    307297        public function add_hooks() {
    308                 add_action( 'wp_enqueue_scripts', array( $this, 'register_script_modules' ) );
    309                 add_action( 'admin_enqueue_scripts', array( $this, 'register_script_modules' ) );
    310 
    311298                add_filter( 'script_module_data_@wordpress/interactivity', array( $this, 'filter_script_module_interactivity_data' ) );
    312299        }
Note: See TracChangeset for help on using the changeset viewer.