Make WordPress Core

Changeset 54308


Ignore:
Timestamp:
09/26/2022 11:40:44 AM (18 months ago)
Author:
gziolo
Message:

Tools: Simplify syncing core blocks from Gutenberg plugin to Core

Follow-up [53688].

Removes the hardcoded list of blocks that should be synced from the Gutenberg plugin. webpack reads all information from the @wordpress/block-library by scanning block.json files.

Props zieladam, azaozz.
Fixes #56179.

File:
1 edited

Legend:

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

    r54307 r54308  
    1414 */
    1515const { normalizeJoin, stylesTransform, baseConfig, baseDir } = require( './shared' );
     16const {
     17    isDynamic,
     18    toDirectoryName,
     19    getStableBlocksMetadata,
     20} = require( '../release/sync-stable-blocks' );
    1621
    1722module.exports = function( env = { environment: 'production', watch: false, buildTarget: false } ) {
     
    1924    const suffix = mode === 'production' ? '.min' : '';
    2025    let buildTarget = env.buildTarget ? env.buildTarget : ( mode === 'production' ? 'build' : 'src' );
    21     buildTarget = buildTarget  + '/wp-includes';
     26    buildTarget = buildTarget + '/wp-includes';
    2227
    23     const dynamicBlockFolders = [
    24         'archives',
    25         'avatar',
    26         'block',
    27         'calendar',
    28         'categories',
    29         'comment-author-name',
    30         'comment-content',
    31         'comment-date',
    32         'comment-edit-link',
    33         'comment-reply-link',
    34         'comment-template',
    35         'comments',
    36         'comments-pagination',
    37         'comments-pagination-next',
    38         'comments-pagination-numbers',
    39         'comments-pagination-previous',
    40         'comments-title',
    41         'cover',
    42         'file',
    43         'gallery',
    44         'home-link',
    45         'image',
    46         'latest-comments',
    47         'latest-posts',
    48         'loginout',
    49         'navigation',
    50         'navigation-link',
    51         'navigation-submenu',
    52         'page-list',
    53         'pattern',
    54         'post-author',
    55         'post-author-biography',
    56         'post-comments-form',
    57         'post-content',
    58         'post-date',
    59         'post-excerpt',
    60         'post-featured-image',
    61         'post-navigation-link',
    62         'post-template',
    63         'post-terms',
    64         'post-title',
    65         'query',
    66         'query-no-results',
    67         'query-pagination',
    68         'query-pagination-next',
    69         'query-pagination-numbers',
    70         'query-pagination-previous',
    71         'query-title',
    72         'read-more',
    73         'rss',
    74         'search',
    75         'shortcode',
    76         'site-logo',
    77         'site-tagline',
    78         'site-title',
    79         'social-link',
    80         'tag-cloud',
    81         'template-part',
    82         'term-description',
    83     ];
    84     const blockFolders = [
    85         'audio',
    86         'button',
    87         'buttons',
    88         'code',
    89         'column',
    90         'columns',
    91         'embed',
    92         'freeform',
    93         'group',
    94         'heading',
    95         'html',
    96         'list',
    97         'list-item',
    98         'media-text',
    99         'missing',
    100         'more',
    101         'nextpage',
    102         'paragraph',
    103         'preformatted',
    104         'pullquote',
    105         'quote',
    106         'separator',
    107         'social-links',
    108         'spacer',
    109         'table',
    110         'text-columns',
    111         'verse',
    112         'video',
    113         ...dynamicBlockFolders,
    114     ];
     28    const blocks = getStableBlocksMetadata();
     29    const dynamicBlockFolders = blocks.filter( isDynamic ).map( toDirectoryName );
     30    const blockFolders = blocks.map( toDirectoryName );
    11531    const blockPHPFiles = {
    11632        'widgets/src/blocks/legacy-widget/index.php': 'wp-includes/blocks/legacy-widget.php',
     
    11935            files[ `block-library/src/${ blockName }/index.php` ] = `wp-includes/blocks/${ blockName }.php`;
    12036            return files;
    121         } , {} ),
     37        }, {} ),
    12238    };
    12339    const blockMetadataFiles = {
     
    12743            files[ `block-library/src/${ blockName }/block.json` ] = `wp-includes/blocks/${ blockName }/block.json`;
    12844            return files;
    129         } , {} ),
     45        }, {} ),
    13046    };
    13147
     
    16480                'process.env.IS_GUTENBERG_PLUGIN': false,
    16581                'process.env.FORCE_REDUCED_MOTION': JSON.stringify(
    166                     process.env.FORCE_REDUCED_MOTION
     82                    process.env.FORCE_REDUCED_MOTION,
    16783                ),
    16884            } ),
Note: See TracChangeset for help on using the changeset viewer.