Make WordPress Core


Ignore:
Timestamp:
07/28/2021 10:05:01 AM (5 years ago)
Author:
gziolo
Message:

Build: Split packages and blocks to their webpack configs

It aligns with the changes proposed added in Gutenberg: https://github.com/WordPress/gutenberg/pull/33293.

The idea here is to split the growing webpack config into two parts: blocks and packages.

We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages.

As part of the effort, it adds support for viewScript in block.json metadata file that is later translated to $view_script in WP_Block_Type class and exposed as view_script from the REST API endpoint for block types.

Props youknowriad, desrosj, aristath.
Fixes #53690.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-type.php

    r51268 r51501  
    157157
    158158    /**
    159      * Block type editor script handle.
     159     * Block type editor only script handle.
    160160     *
    161161     * @since 5.0.0
     
    165165
    166166    /**
    167      * Block type front end script handle.
     167     * Block type front end and editor script handle.
    168168     *
    169169     * @since 5.0.0
     
    173173
    174174    /**
    175      * Block type editor style handle.
     175     * Block type front end only script handle.
     176     *
     177     * @since 5.9.0
     178     * @var string|null
     179     */
     180    public $view_script = null;
     181
     182    /**
     183     * Block type editor only style handle.
    176184     *
    177185     * @since 5.0.0
     
    181189
    182190    /**
    183      * Block type front end style handle.
     191     * Block type front end and editor style handle.
    184192     *
    185193     * @since 5.0.0
     
    199207     * @since 5.6.0 Added the `api_version` property.
    200208     * @since 5.8.0 Added the `variations` property.
     209     * @since 5.9.0 Added the `view_script` property.
    201210     *
    202211     * @see register_block_type()
     
    226235     *     @type array         $uses_context     Context values inherited by blocks of this type.
    227236     *     @type array|null    $provides_context Context provided by blocks of this type.
    228      *     @type string|null   $editor_script    Block type editor script handle.
    229      *     @type string|null   $script           Block type front end script handle.
    230      *     @type string|null   $editor_style     Block type editor style handle.
    231      *     @type string|null   $style            Block type front end style handle.
     237     *     @type string|null   $editor_script    Block type editor only script handle.
     238     *     @type string|null   $script           Block type front end and editor script handle.
     239     *     @type string|null   $view_script      Block type front end only script handle.
     240     *     @type string|null   $editor_style     Block type editor only style handle.
     241     *     @type string|null   $style            Block type front end and editor style handle.
    232242     * }
    233243     */
Note: See TracChangeset for help on using the changeset viewer.