Make WordPress Core

Changeset 47168


Ignore:
Timestamp:
02/02/2020 07:17:07 PM (7 years ago)
Author:
gziolo
Message:

Build: Copy block metadata files for dynamic blocks.

For dynamic blocks, there are several blocks whose metadata needs to be loaded in PHP. The attributes that are loaded via PHP are not exposed to the ReactNative components when Gutenberg loads the index.js files in the Mobile Apps. To support one master set of metadata that can be used to register in the PHP files and the Javascript files; with this patch, the block.json files are copied over with their corresponding PHP files.

Props chipsnyder and azaozz.

Fixes #49196.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/webpack/packages.js

    r47035 r47168  
    9595        };
    9696
     97        const blockNames = [
     98                'archives',
     99                'block',
     100                'calendar',
     101                'categories',
     102                'latest-comments',
     103                'latest-posts',
     104                'rss',
     105                'search',
     106                'shortcode',
     107                'tag-cloud',
     108        ];
    97109        const phpFiles = {
    98110                'block-serialization-default-parser/parser.php': 'wp-includes/class-wp-block-parser.php',
    99                 'block-library/src/archives/index.php': 'wp-includes/blocks/archives.php',
    100                 'block-library/src/block/index.php': 'wp-includes/blocks/block.php',
    101                 'block-library/src/calendar/index.php': 'wp-includes/blocks/calendar.php',
    102                 'block-library/src/categories/index.php': 'wp-includes/blocks/categories.php',
    103                 'block-library/src/latest-comments/index.php': 'wp-includes/blocks/latest-comments.php',
    104                 'block-library/src/latest-posts/index.php': 'wp-includes/blocks/latest-posts.php',
    105                 'block-library/src/rss/index.php': 'wp-includes/blocks/rss.php',
    106                 'block-library/src/search/index.php': 'wp-includes/blocks/search.php',
    107                 'block-library/src/shortcode/index.php': 'wp-includes/blocks/shortcode.php',
    108                 'block-library/src/tag-cloud/index.php': 'wp-includes/blocks/tag-cloud.php',
     111                ...blockNames.reduce( ( files, blockName ) => {
     112                        files[ `block-library/src/${ blockName }/index.php` ] = `wp-includes/blocks/${ blockName }.php`;
     113                        return files;
     114                } , {} ),
     115        };
     116        const blockMetadataCopies = {
     117                from: join( baseDir, `node_modules/@wordpress/block-library/src/+(${ blockNames.join( '|' ) })/block.json` ),
     118                test: new RegExp( `\/([^/]+)\/block\.json$` ),
     119                to: join( baseDir, `${ buildTarget }/blocks/[1]/block.json` ),
    109120        };
    110121
    … …  
    232243                                        ...cssCopies,
    233244                                        ...phpCopies,
     245                                        blockMetadataCopies,
    234246                                ],
    235247                        ),
Note: See TracChangeset for help on using the changeset viewer.