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/tests/phpunit/tests/blocks/register.php

    r51491 r51501  
    134134        );
    135135        $this->assertSame(
     136            'unit-tests-my-block-view-script',
     137            generate_block_asset_handle( $block_name, 'viewScript' )
     138        );
     139        $this->assertSame(
    136140            'unit-tests-my-block-editor-style',
    137141            generate_block_asset_handle( $block_name, 'editorStyle' )
     
    156160            'wp-block-paragraph',
    157161            generate_block_asset_handle( $block_name, 'script' )
     162        );
     163        $this->assertSame(
     164            'wp-block-paragraph-view',
     165            generate_block_asset_handle( $block_name, 'viewScript' )
    158166        );
    159167        $this->assertSame(
     
    373381        $this->assertSame( 'tests-notice-editor-script', $result->editor_script );
    374382        $this->assertSame( 'tests-notice-script', $result->script );
     383        $this->assertSame( 'tests-notice-view-script', $result->view_script );
    375384        $this->assertSame( 'tests-notice-editor-style', $result->editor_style );
    376385        $this->assertSame( 'tests-notice-style', $result->style );
Note: See TracChangeset for help on using the changeset viewer.