Skip to content

Commit 22294af

Browse files
committed
Build: Update Gutenberg integration to checkout-and-build approach.
This changes WordPress Core's Gutenberg integration from npm packages to checking out and building Gutenberg directly. Instead of syncing individual npm packages, Core now checks out the Gutenberg repository, builds it, and copies the build artifacts. This enables Core to use Gutenberg's advanced features like route-based navigation, full-page rendering, and the Font Library, while also streamlining future updates. New commands: * `npm run gutenberg:checkout` - Clones Gutenberg at a specified ref * `npm run gutenberg:build` - Runs Gutenberg's build process * `npm run gutenberg:copy` - Copies and transforms build output to Core * `npm run gutenberg:integrate` - Runs all three steps Main changes: * Removes webpack configs replaced by Gutenberg's build (blocks.js, packages.js, script-modules.js, development.js, vendors.js) * Adds Font Library page (`/wp-admin/font-library.php`) * Adds copy scripts to transform Gutenberg plugin paths to Core paths * Moves vendor copy step from webpack to Gruntfile New year, new process. Happy New Year! Props youknowriad, ellatrix, sirreal, westonruter, desrosj, tellthemachines. Fixes #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@61438 602fd350-edb4-49c9-b593-d223f7449a82
1 parent adc9daf commit 22294af

File tree

235 files changed

+1996
-33457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+1996
-33457
lines changed

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ jobs:
165165
- name: Install npm dependencies
166166
run: npm ci
167167

168+
- name: Build WordPress
169+
run: npm run build:dev
170+
168171
- name: General debug information
169172
run: |
170173
npm --version

.github/workflows/reusable-test-core-build-process.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ on:
3939

4040
env:
4141
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
42+
NODE_OPTIONS: --max-old-space-size=4096
4243

4344
# Disable permissions for all available scopes by default.
4445
# Any needed permissions should be configured at the job level.

.github/workflows/reusable-test-gutenberg-build-process.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

.github/workflows/reusable-test-local-docker-environment-v1.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ jobs:
120120
- name: Install npm dependencies
121121
run: npm ci
122122

123+
- name: Build WordPress
124+
run: npm run build:dev
125+
123126
- name: General debug information
124127
run: |
125128
npm --version

.github/workflows/test-build-processes.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ on:
3232
# Confirm any changes to relevant workflow files.
3333
- '.github/workflows/test-build-processes.yml'
3434
- '.github/workflows/reusable-test-core-build-process.yml'
35-
- '.github/workflows/reusable-test-gutenberg-build-process.yml'
3635
workflow_dispatch:
3736

3837
# Cancels all previous workflow runs for pull requests that have not completed.
@@ -98,54 +97,13 @@ jobs:
9897
os: ${{ matrix.os }}
9998
directory: ${{ matrix.directory }}
10099

101-
# Tests the Gutenberg plugin build process within a wordpress-develop checkout.
102-
test-gutenberg-build-process:
103-
name: Gutenberg running from ${{ matrix.directory }}
104-
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
105-
permissions:
106-
contents: read
107-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
108-
strategy:
109-
fail-fast: false
110-
matrix:
111-
os: [ 'ubuntu-24.04' ]
112-
directory: [ 'src', 'build' ]
113-
with:
114-
os: ${{ matrix.os }}
115-
directory: ${{ matrix.directory }}
116-
117-
# Tests the Gutenberg plugin build process on additional operating systems.
118-
#
119-
# This is separate from the job above in order to use stricter conditions when determining when to test additional
120-
# operating systems. This avoids unintentionally consuming excessive minutes. Windows-based jobs consume minutes at a
121-
# 2x rate, and MacOS-based jobs at a 10x rate.
122-
# See https://docs.github.com/en/billing/concepts/product-billing/github-actions#per-minute-rates.
123-
#
124-
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
125-
# currently no way to determine the OS being used on a given job.
126-
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
127-
test-gutenberg-build-process-additional-os:
128-
name: Gutenberg running from ${{ matrix.directory }}
129-
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
130-
permissions:
131-
contents: read
132-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
133-
strategy:
134-
fail-fast: false
135-
matrix:
136-
os: [ 'macos-15', 'windows-2025' ]
137-
directory: [ 'src', 'build' ]
138-
with:
139-
os: ${{ matrix.os }}
140-
directory: ${{ matrix.directory }}
141-
142100
slack-notifications:
143101
name: Slack Notifications
144102
uses: ./.github/workflows/slack-notifications.yml
145103
permissions:
146104
actions: read
147105
contents: read
148-
needs: [ test-core-build-process, test-core-build-process-additional-os, test-gutenberg-build-process, test-gutenberg-build-process-additional-os ]
106+
needs: [ test-core-build-process, test-core-build-process-additional-os ]
149107
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
150108
with:
151109
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}

.gitignore

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ wp-tests-config.php
2020
/node_modules
2121
/npm-debug.log
2222
/build
23+
/gutenberg
2324
/tests/phpunit/build
2425
/wp-cli.local.yml
2526
/jsdoc
@@ -30,15 +31,18 @@ wp-tests-config.php
3031
/src/wp-admin/css/colors/*/*.css
3132
/src/wp-admin/js
3233
/src/wp-includes/assets/*
33-
!/src/wp-includes/assets/script-loader-packages.min.php
34-
!/src/wp-includes/assets/script-modules-packages.min.php
3534
/src/wp-includes/js
3635
/src/wp-includes/css/dist
3736
/src/wp-includes/css/*.min.css
3837
/src/wp-includes/css/*-rtl.css
39-
/src/wp-includes/blocks/**/*.css
40-
/src/wp-includes/blocks/**/*.js
41-
/src/wp-includes/blocks/**/*.js.map
38+
/src/wp-includes/blocks/*
39+
!/src/wp-includes/blocks/index.php
40+
/src/wp-includes/build
41+
/src/wp-includes/class-wp-block-parser.php
42+
/src/wp-includes/class-wp-block-parser-block.php
43+
/src/wp-includes/class-wp-block-parser-frame.php
44+
/src/wp-includes/theme.json
45+
/src/wp-includes/theme-i18n.json
4246
/packagehash.txt
4347
/artifacts
4448
/setup.log

Gruntfile.js

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/* globals Set */
44
var webpackConfig = require( './webpack.config' );
55
var installChanged = require( 'install-changed' );
6-
var json2php = require( 'json2php' );
76

87
module.exports = function(grunt) {
98
var path = require('path'),
@@ -1279,6 +1278,14 @@ module.exports = function(grunt) {
12791278
BUILD_DIR + 'wp-includes/js/dist/commands.js',
12801279
],
12811280
dest: BUILD_DIR + 'wp-includes/js/dist/'
1281+
},
1282+
{
1283+
expand: true,
1284+
flatten: true,
1285+
src: [
1286+
BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
1287+
],
1288+
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/'
12821289
}
12831290
]
12841291
}
@@ -1414,6 +1421,59 @@ module.exports = function(grunt) {
14141421
grunt.task.run( 'wp-packages:refresh-deps' );
14151422
} );
14161423

1424+
// Gutenberg integration tasks.
1425+
grunt.registerTask( 'gutenberg-checkout', 'Checks out the Gutenberg repository.', function() {
1426+
const done = this.async();
1427+
grunt.util.spawn( {
1428+
cmd: 'node',
1429+
args: [ 'tools/gutenberg/checkout-gutenberg.js' ],
1430+
opts: { stdio: 'inherit' }
1431+
}, function( error ) {
1432+
done( ! error );
1433+
} );
1434+
} );
1435+
1436+
grunt.registerTask( 'gutenberg-build', 'Builds the Gutenberg repository.', function() {
1437+
const done = this.async();
1438+
grunt.util.spawn( {
1439+
cmd: 'node',
1440+
args: [ 'tools/gutenberg/build-gutenberg.js' ],
1441+
opts: { stdio: 'inherit' }
1442+
}, function( error ) {
1443+
done( ! error );
1444+
} );
1445+
} );
1446+
1447+
grunt.registerTask( 'gutenberg-copy', 'Copies Gutenberg build output to WordPress Core.', function() {
1448+
const done = this.async();
1449+
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
1450+
grunt.util.spawn( {
1451+
cmd: 'node',
1452+
args: [ 'tools/gutenberg/copy-gutenberg-build.js', `--build-dir=${ buildDir }` ],
1453+
opts: { stdio: 'inherit' }
1454+
}, function( error ) {
1455+
done( ! error );
1456+
} );
1457+
} );
1458+
1459+
grunt.registerTask( 'gutenberg-integrate', 'Complete Gutenberg integration workflow.', [
1460+
'gutenberg-checkout',
1461+
'gutenberg-build',
1462+
'gutenberg-copy'
1463+
] );
1464+
1465+
grunt.registerTask( 'copy-vendor-scripts', 'Copies vendor scripts from node_modules to wp-includes/js/dist/vendor/.', function() {
1466+
const done = this.async();
1467+
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
1468+
grunt.util.spawn( {
1469+
cmd: 'node',
1470+
args: [ 'tools/vendors/copy-vendors.js', `--build-dir=${ buildDir }` ],
1471+
opts: { stdio: 'inherit' }
1472+
}, function( error ) {
1473+
done( ! error );
1474+
} );
1475+
} );
1476+
14171477
grunt.renameTask( 'watch', '_watch' );
14181478

14191479
grunt.registerTask( 'watch', function() {
@@ -1569,23 +1629,6 @@ module.exports = function(grunt) {
15691629
}
15701630
} );
15711631

1572-
grunt.registerTask( 'copy:block-json', 'Copies block.json file contents to block-json.php.', function() {
1573-
var blocks = {};
1574-
grunt.file.recurse( SOURCE_DIR + 'wp-includes/blocks', function( abspath, rootdir, subdir, filename ) {
1575-
if ( /^block\.json$/.test( filename ) ) {
1576-
blocks[ subdir ] = grunt.file.readJSON( abspath );
1577-
}
1578-
} );
1579-
grunt.file.write(
1580-
SOURCE_DIR + 'wp-includes/blocks/blocks-json.php',
1581-
'<?php return ' + json2php.make( {
1582-
linebreak: '\n',
1583-
indent: ' ',
1584-
shortArraySyntax: false
1585-
} )( blocks ) + ';'
1586-
);
1587-
} );
1588-
15891632
grunt.registerTask( 'copy:js', [
15901633
'copy:npm-packages',
15911634
'copy:vendor-js',
@@ -1723,7 +1766,6 @@ module.exports = function(grunt) {
17231766
grunt.registerTask( 'build:files', [
17241767
'clean:files',
17251768
'copy:files',
1726-
'copy:block-json',
17271769
'copy:version',
17281770
] );
17291771

@@ -1853,6 +1895,8 @@ module.exports = function(grunt) {
18531895
grunt.task.run( [
18541896
'build:js',
18551897
'build:css',
1898+
'gutenberg-integrate',
1899+
'copy-vendor-scripts',
18561900
'build:certificates'
18571901
] );
18581902
} else {
@@ -1861,6 +1905,8 @@ module.exports = function(grunt) {
18611905
'build:files',
18621906
'build:js',
18631907
'build:css',
1908+
'gutenberg-integrate',
1909+
'copy-vendor-scripts',
18641910
'replace:source-maps',
18651911
'verify:build'
18661912
] );

0 commit comments

Comments
 (0)