Skip to content

E2E: Build only the minified bundles - #85252

Closed
sirreal wants to merge 12 commits into
trunkfrom
ci/e2e-build-minified-only
Closed

sirreal wants to merge 12 commits into
trunkfrom
ci/e2e-build-minified-only

Conversation

@sirreal

@sirreal sirreal commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

What?

Adds a --minified-only option to wp-build and uses it in the End-to-End Tests workflow's Build job, so that job builds only what the Playwright tests load.

Why?

Faster builds on CI, lower memory consumption. This is especially important for any private repo forks with less powerful CI runners.

The Playwright jobs run against .wp-env.test.json, which sets SCRIPT_DEBUG to false, so WordPress loads only the .min.js bundles. The Build job still bundles a non-minified copy of every script, script module, route and widget, and writes source maps for the scripts and script modules. These files go into the build artifact and nothing reads them. Phase 2 of the build starts every bundle at once, so these builds add to the job's time and peak memory, and the files add to the artifact upload.

With the option, the Npm build step's median falls from 105 s to 63 s and the artifact from 124 MB to 81 MB; the comparison with recent upstream runs is in #85252 (comment).

How?

  • wp-build --minified-only skips the non-minified bundles (index.js for scripts, *.js for script modules, route.js and content.js for routes, render.js and widget.js for widgets) and the source maps of the minified bundles. The transpiled package output (packages/*/build, packages/*/build-module) and the styles are unchanged.
  • The option is parsed at module level, next to the other build switches, because the non-minified builds happen in bundlePackage(), buildRoute() and buildWidget(), which watch mode also calls.
  • The E2E Build job runs npm run build -- --minified-only.

Without the option, the output is byte-identical to trunk: I built trunk and this branch and compared the paths the E2E workflow uploads with diff -r. With it, 363 files under build/ are not written: 105 non-minified script and module bundles, their 105 source maps, the 105 source maps of the minified bundles, and 48 non-minified route and widget bundles. The minified bundles lose their trailing sourceMappingURL comment, so the content hash in each .min.asset.php changes. Nothing else differs. The uploaded paths shrink from 627 MB to 419 MB locally.

The DROPME: commit sets if: false on every other job that runs on pull requests, so this PR's CI runs only the E2E workflow. It is for measurement and is dropped before merge.

Testing Instructions

  1. npm run build -- --minified-only. build/scripts/*/index.min.js and index.min.asset.php exist; build/scripts/*/index.js and every build/**/*.map do not.
  2. npm run build. The output matches trunk's.
  3. In CI, every Playwright job passes against the reduced build.

Testing Instructions for Keyboard

Not applicable: no UI change.

Use of AI Tools

AI assistance: Yes
Tools: Claude Code
Model: Claude Opus 5.5
Used for: implementation, the build output comparison, the CI measurements and this description.

With --minified-only, wp-build skips the non-minified bundles, which
WordPress loads only when SCRIPT_DEBUG is true, and the source maps of
the minified bundles. This covers the scripts, the script modules, the
routes and the widgets. The transpiled package output in build/ and
build-module/ is unchanged.

Without the option the output is byte-identical to trunk (diff -r over
the paths the E2E workflow uploads). With it, 363 files are not written,
all under build/: 105 non-minified bundles with their source maps and
the source maps of the 105 minified bundles (scripts and modules), plus
48 non-minified route and widget bundles. The minified bundles lose
their sourceMappingURL comment, so the content hash in each
.min.asset.php changes; nothing else differs.

The option is parsed at module level, next to the other build
switches, because the non-minified builds happen in bundlePackage(),
buildRoute() and buildWidget(), which watch mode also calls.
The Playwright jobs run against .wp-env.test.json, which sets
SCRIPT_DEBUG to false, so WordPress loads the .min.js bundles and
nothing reads the non-minified bundles or the source maps. Build with
--minified-only to skip them.
Sets `if: false` on every job of every workflow that runs on pull_request, except end2end-test.yml, so the run measures the E2E Build job and the Playwright jobs alone. Drop before merge.
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>
Co-authored-by: anomiex <bjorsch@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 9.05 MB

1a97c97 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 00dfbba trunk % Change
timeToFirstByte 45.9 ms +11.11% -7.73% 43 ms +9.53% -5.93% 6.74%
largestContentfulPaint 80 ms +2.5% -10% 74 ms +5.41% -8.11% 8.11%
lcpMinusTtfb 30.2 ms +10.43% -5.96% 28.2 ms +20.04% -3.55% 7.09%
wpBeforeTemplate 23.12 ms +22.45% -3.07% 22.07 ms +21.57% -2.49% 4.76%
wpTemplate 17.82 ms +9.6% -7.3% 16.38 ms +7.45% -5.8% 8.79%
wpTotal 42.55 ms +10.39% -8.44% 39.82 ms +8.71% -6.91% 6.86%
wpMemoryUsage 7.65 MB +0% -0% 7.61 MB +0% -0% 0.46%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 00dfbba trunk % Change
timeToFirstByte 36.35 ms +7.7% -1.38% 31.75 ms +6.3% -2.2% 14.49%
largestContentfulPaint 84 ms +0% -0% 72 ms +0% -5.56% 16.67%
lcpMinusTtfb 47.35 ms +1.48% -3.91% 37.8 ms +6.08% -1.46% 25.26%
wpBeforeTemplate 20.24 ms +6.92% -2.47% 19.33 ms +1.14% -1.76% 4.71%
wpTemplate 13.58 ms +1.99% -2.8% 9.57 ms +5.02% -2.3% 41.9%
wpTotal 33.68 ms +7.87% -1.72% 29.3 ms +6.45% -2.56% 14.95%
wpMemoryUsage 6.34 MB +0% -0% 6.19 MB +0% -0% 2.38%
wpDbQueries 13 +0% -0% 9 +0% -0% 44.44%

media-processing

Metric 00dfbba trunk % Change
mediaProcessingJpeg 325.33 ms +2.77% -0.65% 326.27 ms +0.13% -1.41% -0.29%
mediaProcessingAvif 4817.24 ms +0.17% -0.12% 4824.13 ms +0.27% -0.31% -0.14%
mediaProcessingJpegToAvif 3370 ms +0.19% -0.15% 3361.97 ms +0.5% -0.04% 0.24%

media-upload

Metric 00dfbba trunk % Change
jpegUploadProcessing 1419.63 ms +1.28% -0.9% 1398.23 ms +1.31% -0.54% 1.53%
pngUploadProcessing 181.88 ms +6.98% -3.47% 182.1 ms +3.98% -2.09% -0.12%
largeJpegUploadProcessing 1391.49 ms +1.1% -0.44% 1392.81 ms +0.73% -0.64% -0.09%
multipleImageUploadProcessing 1475.02 ms +0.89% -0.32% 1448.17 ms +2.55% -0.1% 1.85%

post-editor

Metric 00dfbba trunk % Change
serverResponse 442.11 ms +6.44% -6.64% 471.57 ms +7.12% -4.41% -6.25%
firstPaint 474.06 ms +1.79% -17.49% 407.04 ms +13.87% -29.93% 16.47%
domContentLoaded 1097.93 ms +2.4% -1.65% 1126.81 ms +0.75% -2.03% -2.56%
loaded 1098.78 ms +2.4% -1.66% 1128.12 ms +0.73% -2.03% -2.6%
firstContentfulPaint 480.37 ms +4.06% -1.82% 472.14 ms +1.48% -4.27% 1.74%
firstBlock 3236.76 ms +1.36% -0.85% 3353.55 ms +4.24% -3% -3.48%
type 16.85 ms +5.58% -6.65% 16.2 ms +16.73% -3.15% 4.01%
typeWithoutInspector 15.97 ms +2.32% -2.76% 17.13 ms +3.91% -3.21% -6.77%
typeWithTopToolbar 21.96 ms +1.09% -7.65% 21.41 ms +4.58% -5.42% 2.57%
typeContainer 7.91 ms +16.56% -5.94% 7.4 ms +8.92% -8.65% 6.89%
focus 113.68 ms +7.27% -4.35% 111.07 ms +1.8% -1.84% 2.35%
firstFocus 202.24 ms +0% -0% 202.69 ms +0% -0% -0.22%
selectAll 532.34 ms +2.84% -3.97% 548.59 ms +0.86% -5.86% -2.96%
listViewOpen 72.11 ms +7.39% -5.78% 72.44 ms +4.67% -5.89% -0.46%
inserterOpen 38.37 ms +6.78% -9.7% 39.42 ms +6.62% -15.93% -2.66%
inserterHover 10.59 ms +14.83% -8.5% 11.34 ms +3% -11.73% -6.61%
inserterSearch 7.68 ms +9.51% -8.2% 8.03 ms +7.47% -11.33% -4.36%
loadPatterns 580.32 ms +1.72% -3.1% 571.87 ms +5.33% -2.58% 1.48%
wpTotal 432.56 ms +6.6% -6.78% 461.93 ms +7.06% -4.46% -6.36%
wpMemoryUsage 14.69 MB +0% -0% 14.65 MB +0% -0% 0.26%
wpDbQueries 55 +0% -1.82% 55 +0% -1.82% 0%

site-editor

Metric 00dfbba trunk % Change
serverResponse 502.55 ms +4.08% -7.9% 489.59 ms +5.59% -4.09% 2.65%
firstPaint 280.61 ms +17.08% -16.81% 253.47 ms +28.04% -15.4% 10.71%
domContentLoaded 1301.95 ms +2.58% -3.35% 1282.78 ms +1.29% -0.86% 1.49%
loaded 1303.18 ms +2.58% -3.37% 1284.03 ms +1.28% -0.87% 1.49%
firstContentfulPaint 520.88 ms +4.13% -6.09% 503.72 ms +2.17% -28.27% 3.41%
firstBlock 4788.56 ms +1.38% -1.15% 4794.89 ms +0.14% -0.8% -0.13%
type 19.78 ms +5.81% -2.88% 19.86 ms +1.56% -4.93% -0.4%
navigate 130.32 ms +12.87% -2.39% 129.95 ms +8.56% -2.64% 0.28%
loadPatterns 1278.15 ms +10.19% -12.5% 1282.14 ms +13.84% -1.8% -0.31%
loadPages 984.08 ms +2.44% -1.12% 981.47 ms +2.66% -1.78% 0.27%
wpTotal 493.1 ms +4.18% -8.07% 480.35 ms +5.72% -4.13% 2.65%
wpMemoryUsage 12.70 MB +0% -0% 12.67 MB +0% -0% 0.29%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

1a97c97 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Regression: updating a specific option will only change its value and will not corrupt others in /test/e2e/specs/editor/various/core-settings.spec.js, passed after 1 failed attempt.
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
    "rewrite_rules",
-   "SERIALIZED DATA",
+   "",
  ]
    at forEach (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:46:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:43:35
The editable block version is rendered if the legacy attribute is false in /test/e2e/specs/editor/blocks/comments.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/users/me
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: baae937610
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1792755167%7Ch6fUy0Tatdid2PKiGexD55Hs0BC0zwOuBfrL7ULg5St%7C4bf8b72369ead48681380895f5a659bfd17bfbd10bf87b76feda1e74cdb59ae8; wp-settings-time-1=1792582408

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at RequestUtils.createComment (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/comments.ts:29:33)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/comments.spec.js:185:22
refuses the drop and uploads nothing in /test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js, passed after 1 failed attempt.
Error: expect(received).toHaveLength(expected)

Expected length: 0
Received length: 1
Received array:  [{"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "curies": [{"href": "https://api.w.org/{rel}", "name": "wp", "templated": true}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=223"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/223", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}], "wp:attached-to": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/posts/222", "id": 222, "post_type": "post"}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-223", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-10-21T11:40:48", "date_gmt": "2026-10-21T11:40:48", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/10/36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/10/36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/10/36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png"}, "id": 223, "link": "http://localhost:8889/?attachment_id=223", "media_details": {"file": "2026/10/36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-10-21T11:40:48", "modified_gmt": "2026-10-21T11:40:48", "ping_status": "closed", "post": 222, "slug": "36a17df4-2078-4b3e-8bdb-20b8d1b45b3e", "source_url": "http://localhost:8889/wp-content/uploads/2026/10/36a17df4-2078-4b3e-8bdb-20b8d1b45b3e.png", "status": "inherit", "template": "", "title": {"rendered": "36a17df4-2078-4b3e-8bdb-20b8d1b45b3e"}, "type": "attachment"}]
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js:71:45
restores the blocks when a multi-selection drag is canceled in /test/e2e/specs/editor/various/draggable-blocks.spec.js, passed after 1 failed attempt.
TypeError: Cannot read properties of null (reading 'y')
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:824:57
    at dragSelectionBelowLanding (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:823:3)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:871:3

1a97c97 Run

@github-actions github-actions Bot added the [Package] wp-build /packages/wp-build label Oct 21, 2026
@sirreal sirreal added the [Type] Build Tooling Issues or PRs related to build tooling label Oct 21, 2026
@sirreal

sirreal commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

Build job timings on ubuntu-24.04. This PR: the Build job of run 39550857144, attempts 1 to 3 (attempts 2 and 3 rerun the Build job and the jobs that need it). Upstream: the 15 most recent successful E2E Build jobs on other PRs and trunk, started between 05:21 and 06:14 UTC today. Phase times are the gaps between the timestamps of the Phase N log lines. Median, with the range in parentheses.

Upstream, 15 jobs This PR, 3 jobs
Build job (s) 175 (123–192) 118 (114–141)
Npm build step (s) 105 (72–113) 63 (60–81)
Before Phase 1 (deps check, workspaces, types, vendors) (s) 23.3 (17.4–25.3) 19.3 (18.9–23.4)
Phase 1: Transpiling packages (s) 27.5 (18.6–30.6) 22.1 (20.1–28.8)
Phase 2: Bundling packages (s) 29.9 (19.3–31.3) 11.1 (10.8–14.5)
Phase 3: Building routes (s) 15.3 (10.7–16.3) 6.5 (6.2–8)
Phase 4: Building widgets (s) 7.1 (4.9–7.8) 3.2 (2.6–4)
Upload build output step (s) 34 (22–38) 21 (21–28)
Artifact size (MB) 123.5 (123.5–123.7) 81.3 (81.3–81.3)

Phases 2 to 4, which contained the skipped builds, take 55% to 63% less time: their medians drop by 31.5 s in total, and the Npm build median by 42 s. Phase 1 and the steps before it run the same code in both columns and their ranges overlap, so I read the rest of the difference as runner variance. The artifact is 34% smaller and uploads in 13 s less. The Playwright jobs download it in the same time as before (median 9 s in both).

Peak memory does not appear in the job log. Locally (Apple M5 Max, 18 cores), the summed resident memory of the build's process tree, sampled every 0.25 s, peaked at 9.7 GB and 8.1 GB in two default builds and at 5.8 GB and 4.9 GB in two --minified-only builds. Within Phase 2 the peak was 7.6 GB by default and 3.4 GB with the option.

All 10 Playwright jobs passed in each of the three attempts. The flaky test report lists tests that failed once and passed on retry: core-settings.spec.js, single-file-placeholder-drop.spec.js and draggable-blocks.spec.js in every attempt, which the upstream runs above also report as flaky, and customizing-widgets.spec.js once in attempt 3 (#44672).

Leave the parseArgs() call in main(), where trunk has it, and store the
flag in a module-level variable that main() sets before buildAll() and
watchMode() run.
Both tests fail with a TypeError thrown from serializeBlock() in the
wp-blocks bundle, once through page.evaluate() and once as an uncaught
page error, so the CI report shows whether Playwright maps the stack
trace through the bundle's source map. Drop before merge.
Restores trunk's sourcemap settings for the minified scripts and script
modules, so the E2E run shows whether the failing probe spec reports
source-mapped stack traces when the maps are present. Drop before merge.
@sirreal
sirreal marked this pull request as ready for review October 21, 2026 11:27
@sirreal
sirreal requested a review from desrosj as a code owner October 21, 2026 11:27
@youknowriad

Copy link
Copy Markdown
Contributor

I think some folks from Jetpack were asking for this option as well and have an alternative PR. Not just for e2e test but also for their own production builds. So let's make sure it fits both use-cases and consider the earlier PR.

@youknowriad

Copy link
Copy Markdown
Contributor

I think it's this PR #75396

@simison

simison commented Oct 22, 2026

Copy link
Copy Markdown
Member

cc @anomiex @tbradsha and @kraftbj can you help take a look since you were interested in #75396 ?

@anomiex

anomiex commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Something that has come up since we were looking at #75396 is the problem of i18n. GlotPress only scans the non-minified filename (or the .map file, but breaks if that contains any TypeScript). Our current solution is to take the non-minified bundle and strip it down to only the i18n function calls, while only ever loading the minified bundle.

Given our experience with producing GlotPress-compatible minified bundles from Webpack+terser, I'd expect that, even if we renamed the .min.js bundles so GlotPress would scan them, it would miss stuff in many cases (if it preserves the __ function names at all, anything minified from cond ? __( 'foo', 'domain' ) : __( 'bar', 'domain' ) to __(cond?'foo':'bar','domain') breaks, for example) and lose all translator comments.

@sirreal

sirreal commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

My main driver here was to reduce memory and prevent out-of-memory build failures on CI. With #79889, I believe that's resolved. I don't have a pressing need for this now.

@sirreal

sirreal commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #75396.

@sirreal sirreal closed this Nov 16, 2026
@sirreal
sirreal deleted the ci/e2e-build-minified-only branch November 16, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] wp-build /packages/wp-build [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants