Skip to content

Build: Skip sourcemaps for WASM-inlined script module workers#75993

Merged
adamsilverstein merged 13 commits into
trunkfrom
64734-built-vips-too-large
Apr 24, 2026
Merged

Build: Skip sourcemaps for WASM-inlined script module workers#75993
adamsilverstein merged 13 commits into
trunkfrom
64734-built-vips-too-large

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Feb 27, 2026

Summary

Suppresses source map generation for WASM-inlined worker builds (currently only @wordpress/vips/worker). The worker is ~13MB of base64-encoded WASM data where source maps provide no debugging value, yet the .map file is nearly the same size (~13MB).

This builds on #76615 (skip unminified worker build) and #76639 (remove unused JXL WASM) which already landed on trunk.

Size impact

Trunk This PR Saved
build/modules/vips/ 26 MB 10 MB 16 MB
Plugin ZIP 33 MB 27 MB ~6 MB (18%)

What changed

The only functional change is setting sourcemap: ! isWasmWorker in the esbuild config for script module builds. This skips generating worker.min.js.map (~13MB) and the unminified loader's .map files for packages whose exports correspond to wpWorkers entries.

Files removed from build/modules/vips/

File Size Status
worker.min.js.map 13.2 MB Removed by this PR
loader.js.map 999 B Removed by this PR
loader.min.js.map 1,006 B Removed by this PR
loader.js (unminified) 173 B Removed by this PR
worker.js (unminified) ~13 MB Already removed by #76615
vips-jxl.wasm (inlined) ~3 MB Already removed by #76639

Context

Fixes #64734

See also:

Test plan

  • npm run build — verify build/modules/vips/ contains only worker.min.js, loader.min.js, and *.asset.php (no .map files)
  • Verify other script modules still have source maps (e.g. ls build/modules/interactivity/)
  • Upload an image in the editor — verify VIPS processing works correctly

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 27, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>

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

@adamsilverstein adamsilverstein added [Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling [Feature] Client Side Media Media processing in the browser with WASM labels Feb 27, 2026
@adamsilverstein adamsilverstein self-assigned this Feb 27, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs Review in WordPress 7.0 Editor Tasks Feb 27, 2026
@github-actions github-actions Bot added [Package] Compose /packages/compose [Package] Core data /packages/core-data [Package] Components /packages/components [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Rich text /packages/rich-text [Package] Block editor /packages/block-editor [Package] Edit Site /packages/edit-site [Package] Private APIs /packages/private-apis labels Feb 27, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Mar 2, 2026

@adamsilverstein, have you tested with SCRIPT_DEBUG enabled? The plugin and core will use non-minified files when script debugging is enabled. If the file doesn't exist, this could potentially break things. At least it will produce a 404 error.

We might have to add special handling for this file. Here's a related discussion - #75396.

@andrewserong
Copy link
Copy Markdown
Contributor

We might have to add special handling for this file. Here's a related discussion - #75396.

Thanks for flagging — that's interesting, that case is about an environment-based flag (i.e. running a production build), whereas this case is about the package itself having an opinion on how it's built. I wonder if there's a way to combine these concepts / features into a single idea. Or failing that, closely related ones 🤔

@adamsilverstein
Copy link
Copy Markdown
Member Author

@adamsilverstein, have you tested with SCRIPT_DEBUG enabled? The plugin and core will use non-minified files when script debugging is enabled. If the file doesn't exist, this could potentially break things. At least it will produce a 404 error.

We might have to add special handling for this file. Here's a related discussion - #75396.

That makes sense. My local is loading the core version now on trunk, so I need to test against 6.9.

@adamsilverstein
Copy link
Copy Markdown
Member Author

I verified this is causing an issue with 6.9, working on it.

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Mar 2, 2026

Thanks for the confirmation, @adamsilverstein! I think we'll have the same issue with 7.0 once changes are synced.

@youknowriad
Copy link
Copy Markdown
Contributor

What's the reasoning for wanting to skip these files. What is special for these packages compared to all the other ones?

@adamsilverstein
Copy link
Copy Markdown
Member Author

What's the reasoning for wanting to skip these files. What is special for these packages compared to all the other ones?

Their very large size. This fixes https://core.trac.wordpress.org/ticket/64734 see that ticket for details.

@youknowriad - If preferable we can ship these files with Gutenberg, but omit them during the WordPress build process. what do you think?

@youknowriad
Copy link
Copy Markdown
Contributor

@youknowriad - If preferable we can ship these files with Gutenberg, but omit them during the WordPress build process. what do you think?

I'm not sure, I see Gutenberg as alpha, so I believe we should do the same.

It seems like the "wasm" package is a good enough differentiation to consider it special.

--

Should we name the flag wpScriptDebugSupport: true/false and support it for all the outputs of a given package (styles, scripts or script modules)

@adamsilverstein
Copy link
Copy Markdown
Member Author

Should we name the flag wpScriptDebugSupport: true/false and support it for all the outputs of a given package (styles, scripts or script modules)

that makes sense, and i assume the default is true since we normally do support debugging by outputting map files and unminified versions.

@adamsilverstein
Copy link
Copy Markdown
Member Author

adamsilverstein commented Mar 2, 2026

I started working on a simpler solution for core since we probably need to adjust loading there as well to always use the minified VIPS file: WordPress/wordpress-develop#11109

The previous commit added wpScriptModuleMinifiedOnly to
package.json but didn't pass the flag through to the PHP
registry data. Without the minified_only entry in the
registry, the PHP template couldn't override the .js
extension when SCRIPT_DEBUG is on, causing module resolution
failures for packages that only ship .min.js files.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

Flaky tests detected in 43735c6.
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.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23452985817
📝 Reported issues:

adamsilverstein and others added 3 commits March 3, 2026 11:11
Broadens the flag to cover all build outputs (scripts, script
modules, and styles) instead of just script modules. When set
to false, skips unminified builds and sourcemaps for all
output types. Adds file_exists fallbacks in script and style
PHP templates so SCRIPT_DEBUG gracefully falls back to
minified files when unminified versions don't exist.
The file_exists fallback in the PHP template handles missing
unminified files generically, making the per-module
minified_only flag in the registry unnecessary.
- Collapse multiline `skipDebugBuilds` assignments to single lines (prettier)
- Re-align JSDoc @typedef/@Property columns in package-utils.mjs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@youknowriad
Copy link
Copy Markdown
Contributor

This is looking good for me.

@desrosj
Copy link
Copy Markdown
Member

desrosj commented Mar 20, 2026

@adamsilverstein is this still needed after the recent work to shrink the related source?

@adamsilverstein
Copy link
Copy Markdown
Member Author

adamsilverstein commented Mar 21, 2026

Maybe not? We might still want it to reduce Gutenberg's package size.

@adamsilverstein
Copy link
Copy Markdown
Member Author

@adamsilverstein is this still needed after the recent work to shrink the related source?

we do still want this PR:

Plugin ZIP Size

Size
Trunk (current) 33 MB (34,154,414 bytes)
PR #75993 27 MB (27,890,699 bytes)
Savings ~6 MB (18%)

Build Directory

Trunk PR Saved
build/ total 132 MB 113 MB 19 MB
build/modules/vips/ 26 MB 10 MB 16 MB
.map files in build/modules/ 19.2 MB 5.8 MB 13.4 MB

What the PR still removes vs current trunk

The recent PRs (#76615, #76639, #76657) already landed the unminified worker skip, JXL WASM removal, and SCRIPT_DEBUG fallback. What this PR still does on top of trunk:

File removed Size
vips/worker.min.js.map 13.2 MB
vips/loader.js (unminified) 173 B
vips/loader.js.map 999 B
vips/loader.min.js.map 1,006 B
Total additional savings ~13.2 MB from build, ~6 MB from ZIP

The remaining value of this PR is removing source maps from the vips build output, which saves ~13 MB from the build directory and ~6 MB from the plugin ZIP. The non-vips source maps (5.8 MB) are still present in both builds.

adamsilverstein and others added 4 commits March 23, 2026 10:54
Resolve conflicts with #76615 and #76657 which landed the unminified
worker skip and SCRIPT_DEBUG fallback. Keep trunk's isWasmWorker/min_only
approach and add sourcemap suppression for WASM workers. Remove the
unused wpScriptDebugSupport flag and related dead code paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@adamsilverstein
Copy link
Copy Markdown
Member Author

@youknowriad can you please approve this if it looks good to you?

@adamsilverstein
Copy link
Copy Markdown
Member Author

This worked well in my local testing.

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

Labels

[Feature] Client Side Media Media processing in the browser with WASM [Status] In Progress Tracking issues with work in progress [Type] Build Tooling Issues or PRs related to build tooling

Projects

Development

Successfully merging this pull request may close these issues.

5 participants