Repository navigation
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.86 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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
|
There was a problem hiding this comment.
🟢 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
.mapfiles from the archive. - Strips trailing
sourceMappingURLcomments 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
Example load effect comparing this pull request from another recent one (#87918 in this example), looking at Playground's Before: After: |
Yep that should still work. But very easy to confirm by running |
What?
Updates the Gutenberg plugin artifact creation step to exclude
.mapfiles, and strip correspondingsourceMappingURL.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)
The behavior is also consistent with
wordpress-develop, which also has similar logic to strip sourcemap comments in its build.How?
Excludes
.mapfiles from the built plugin zip as part of thebuild-plugin-ziptool artifact creation.If you look at the
.mapfiles, 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.mapon 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
.mapfiles, but since the built files will include a reference to them in the concludingsourceMappingURLline, 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
.mapfiles can have some relevance to string extraction, aswp-cli/i18n-commandwill 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.jswith 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 devornpm run build.Verify that the plugin zip is still functional by creating the zip through
npm run build:plugin-zipand 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.