Skip to content

Build Tooling: Reduce size of plugin zip by omitting map files - #87917

Open
aduth wants to merge 2 commits into
trunkfrom
remove/built-plugin-zip-maps
Open

aduth wants to merge 2 commits into
trunkfrom
remove/built-plugin-zip-maps

Conversation

@aduth

@aduth aduth commented Dec 3, 2026

Copy link
Copy Markdown
Member

What?

Updates the Gutenberg plugin artifact creation step to exclude .map files, and strip corresponding sourceMappingURL.

Why?

This reduces the size of the plugin by about half, without any regression in how the plugin is used today. Reducing the size of the plugin makes it faster to install, which extends to sites using Gutenberg, as well as environments like Playground (e.g. the "Preview" links shown in the "PR Meta" comment should be faster to load)

Files Unzipped Zipped
Before 2,302 267.1 MB 54.7 MB
After 2,092 143.4 MB 29.2 MB
Diff −210 −123.7 MB (−46%) −25.5 MB (−47%)

The behavior is also consistent with wordpress-develop, which also has similar logic to strip sourcemap comments in its build.

How?

Excludes .map files from the built plugin zip as part of the build-plugin-zip tool artifact creation.

If you look at the .map files, you'll see that they reference relative paths to the Gutenberg project source, which is not included in the zips.

For example, build/modules/a11y/index.js.map on trunk has content like:

{"sources":["../../../packages/a11y/build-module/shared/clear.mjs"]}

These are useful for local development for contributors working in Gutenberg, but the files don't exist in the plugin. That's why the code here changes the plugin zip preparation and not the build itself.

It's mostly enough to just remove the .map files, but since the built files will include a reference to them in the concluding sourceMappingURL line, the build is also updated to strip those comments. Without this, a browser may warn about 404 on the missing map file.

It's worth noting that .map files can have some relevance to string extraction, as wp-cli/i18n-command will try to use a map file to extract strings if it would otherwise by dropped by a minified .min.js. My understanding is that as long as we're still shipping the .js with translator comments intact (since #87189), it can still extract strings from that script (cc @swissspidy ).

Testing Instructions

Verify that you can still use sourcemaps in local development when running through npm run dev or npm run build.

Verify that the plugin zip is still functional by creating the zip through npm run build:plugin-zip and installing it on a site.

Alternatively, the easiest option to verify is by using the "Preview" links in the "PR Meta" comment below, which uses the built plugin artifact published through the "Build Gutenberg Plugin Zip" workflow that generates the plugin zip using this code. It should hopefully be a bit faster to load as well.

Use of AI Tools

Claude Code + Opus 5.5.

@aduth
aduth requested a review from manzoorwanijk as a code owner December 3, 2026 17:02
@aduth aduth added the [Type] Build Tooling Issues or PRs related to build tooling label Dec 3, 2026
Copilot AI balanced review requested due to automatic review settings December 3, 2026 17:02
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 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: aduth <aduth@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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

📦 Bundle size

Size Change: 0 B

Total Size: 8.86 MB

cad58e3 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 6bae494 trunk % Change
timeToFirstByte 59.5 ms +1.18% -3.19% 59.95 ms +4.17% -3.84% -0.75%
largestContentfulPaint 92 ms +6.52% -4.35% 96 ms +4.17% -8.33% -4.17%
lcpMinusTtfb 32.05 ms +21.37% -6.24% 35.55 ms +8.72% -15.61% -9.85%
wpBeforeTemplate 31.21 ms +4.45% -2.82% 31.18 ms +7.18% -2.89% 0.1%
wpTemplate 23.8 ms +1.76% -4.29% 23.98 ms +1.38% -3.84% -0.75%
wpTotal 55.23 ms +1.81% -2.57% 55.82 ms +4.03% -3.28% -1.06%
wpMemoryUsage 7.76 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 6bae494 trunk % Change
timeToFirstByte 49.65 ms +9.67% -3.02% 48.65 ms +11.2% -2.88% 2.06%
largestContentfulPaint 84 ms +9.52% -0% 84 ms +4.76% -0% 0%
lcpMinusTtfb 35.9 ms +3.76% -3.06% 36.2 ms +2.35% -3.45% -0.83%
wpBeforeTemplate 30.29 ms +7% -8.91% 27.72 ms +5.63% -1.62% 9.27%
wpTemplate 16.8 ms +7.92% -3.75% 17.23 ms +4.06% -4.12% -2.5%
wpTotal 46.45 ms +9.49% -3.14% 44.93 ms +9.3% -2.11% 3.38%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 6bae494 trunk % Change
mediaProcessingJpeg 400.59 ms +1.19% -1.12% 400.8 ms +0.58% -0.49% -0.05%
mediaProcessingAvif 6169.22 ms +0.56% -0.69% 6118.49 ms +0.82% -0.1% 0.83%
mediaProcessingJpegToAvif 4236.52 ms +0.24% -0.13% 4243.34 ms +0.15% -0.27% -0.16%

media-upload

Metric 6bae494 trunk % Change
jpegUploadProcessing 1748.42 ms +16.44% -13.98% 1504.58 ms +2.14% -1.39% 16.21%
pngUploadProcessing 270.62 ms +4.07% -2.45% 274.85 ms +2.11% -3.22% -1.54%
largeJpegUploadProcessing 1740.88 ms +11.98% -12.61% 1722.85 ms +14.57% -13.05% 1.05%
multipleImageUploadProcessing 2034.66 ms +1.4% -18.16% 2068.4 ms +1.71% -4.8% -1.63%

post-editor

Metric 6bae494 trunk % Change
serverResponse 408.22 ms +3.24% -6.58% 418.34 ms +0.88% -9.58% -2.42%
firstPaint 411.07 ms +8.47% -4.92% 412.01 ms +6.49% -12.5% -0.23%
domContentLoaded 801.79 ms +1.95% -0.44% 802.31 ms +1.11% -0.94% -0.06%
loaded 803.22 ms +1.9% -0.48% 803.61 ms +1.12% -0.97% -0.05%
firstContentfulPaint 442.57 ms +3.51% -1.26% 444.76 ms +1.12% -2.22% -0.49%
firstBlock 2125.29 ms +2.34% -2.84% 2106.41 ms +0.99% -0.65% 0.9%
type 17.02 ms +8.75% -7.93% 16.98 ms +4.95% -13.66% 0.24%
typeWithoutInspector 16.25 ms +9.05% -7.08% 17.25 ms +6.09% -9.28% -5.8%
typeWithTopToolbar 22.19 ms +5.99% -8.2% 21.42 ms +4.39% -7.24% 3.59%
typeContainer 8.08 ms +10.27% -6.56% 8.35 ms +10.9% -5.87% -3.23%
focus 107.49 ms +9.1% -3.71% 112.75 ms +6.86% -3.31% -4.67%
firstFocus 263.38 ms +0% -0% 253.98 ms +0% -0% 3.7%
selectAll 334.94 ms +2.58% -0.29% 344.05 ms +0.11% -1.37% -2.65%
undo 29.29 ms +7.68% -2.7% 30.36 ms +6.88% -3.75% -3.52%
listViewOpen 38.26 ms +10.27% -2.06% 38.06 ms +9.33% -7.38% 0.53%
inserterOpen 43.31 ms +1.48% -8.75% 39.84 ms +11.57% -1.88% 8.71%
inserterHover 11.74 ms +5.45% -10.48% 11.32 ms +10.87% -8.39% 3.71%
inserterSearch 8.56 ms +5.72% -11.21% 8.71 ms +8.38% -2.87% -1.72%
loadPatterns 705.8 ms +1.02% -3.32% 693.46 ms +4.65% -3.52% 1.78%
wpTotal 398.66 ms +3.3% -6.65% 408.93 ms +0.88% -9.81% -2.51%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 6bae494 trunk % Change
serverResponse 464.15 ms +0.83% -8.44% 459.24 ms +1.9% -7.5% 1.07%
firstPaint 451.34 ms +2.59% -17.83% 402.46 ms +10.9% -10.22% 12.15%
domContentLoaded 816.78 ms +4.25% -0.78% 812.5 ms +1.31% -1.5% 0.53%
loaded 817.93 ms +4.28% -0.75% 813.9 ms +1.3% -1.52% 0.5%
firstContentfulPaint 454.39 ms +1.91% -0.88% 450.88 ms +3.33% -2.89% 0.78%
firstBlock 2562 ms +6.23% -0.9% 2555.27 ms +2.01% -1.11% 0.26%
type 16.62 ms +7.34% -7.94% 15.95 ms +3.13% -6.14% 4.2%
navigate 105.73 ms +4.69% -3.48% 109.76 ms +10.73% -1.43% -3.67%
loadPatterns 1629.6 ms +3.58% -7.06% 1566.54 ms +13.65% -2.74% 4.03%
loadPages 940.24 ms +2.05% -2.56% 962.58 ms +1.48% -2.15% -2.32%
wpTotal 454.8 ms +0.81% -8.64% 449.64 ms +1.94% -7.61% 1.15%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

cad58e3 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.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4
Navigates the items list via UP/DOWN arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page Two') with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-201-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-201-label" aria-describedby="view-list-0-201-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:146:49
shows a Global Styles scale and lets a heading override it in /test/e2e/specs/editor/various/block-transform.spec.ts, passed after 1 failed attempt.
Error: Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-transform.spec.ts:820:6

cad58e3 Run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues with the source-map packaging changes.

No open issues 🎉

What changed in this PR

Reduces the Gutenberg plugin ZIP size by removing source maps during packaging, while preserving them in local builds.

Changes:

  • Excludes .map files from the archive.
  • Strips trailing sourceMappingURL comments from packaged JavaScript.
File Description
tools/​release/​build-plugin-zip.mts Omits source maps and removes their JavaScript references during ZIP creation.

Review effort: Balanced

@aduth

aduth commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Alternatively, the easiest option to verify is by using the "Preview" links in the "PR Meta" comment below

Example load effect comparing this pull request from another recent one (#87918 in this example), looking at Playground's plugin-proxy.php request in Chrome's Network tab.

Before:

Pasted 2026-12-03 at 1 05 10 PM

After:

Screenshot 2026-12-03 at 1 05 53 PM

@swissspidy

Copy link
Copy Markdown
Member

It's worth noting that .map files can have some relevance to string extraction, as wp-cli/i18n-command will try to use a map file to extract strings if it would otherwise by dropped by a minified .min.js

wp i18n make-json has a concept of a map file but that has nothing to do with source maps. It's only a way to make sure the JSON translation files contain the correct strings for a given (minified) JS file.

My understanding is that as long as we're still shipping the .js with translator comments intact (since #87189), it can still extract strings from that script

Yep that should still work. But very easy to confirm by running wp i18n make-pot on the new zip file.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants