Skip to content

WASM: Build Optimizations - #1075

Merged
marcoroth merged 1 commit into
mainfrom
wasm-build-optimizations
Jan 17, 2026
Merged

WASM: Build Optimizations#1075
marcoroth merged 1 commit into
mainfrom
wasm-build-optimizations

Conversation

@marcoroth

@marcoroth marcoroth commented Jan 17, 2026

Copy link
Copy Markdown
Owner

This pull request applies size optimizations to the WebAssembly build, inspired by ruby/prism#3824.

The WASM bindings don't use Prism's prettyprint, JSON serialization, or pack parsing features, so we can exclude these features by defining PRISM_EXCLUDE_PRETTYPRINT, PRISM_EXCLUDE_JSON, and PRISM_EXCLUDE_PACK.

Added -Oz (optimize for size), -g0 (strip debug info), -flto (link-time optimization), and -fdata-sections -ffunction-sections (enable dead code elimination) to produce smaller output.

Excluded ruby_parser.c from the WASM build since it's only used for CLI debugging.

Results

Build Before After Reduction
Browser 905K 365K -540K (~60%)
Node 907K 365K -542K (~60%)
Details

Before:

ls -lh javascript/packages/browser/build/libherb.js javascript/packages/node-wasm/build/libherb.js
-rw-r--r--@ 1 marcoroth  staff   905K Jan 17 11:17 javascript/packages/browser/build/libherb.js
-rw-r--r--@ 1 marcoroth  staff   907K Jan 17 11:17 javascript/packages/node-wasm/build/libherb.js

After:

ls -lh javascript/packages/browser/build/libherb.js javascript/packages/node-wasm/build/libherb.js
-rw-r--r--@ 1 marcoroth  staff   365K Jan 17 11:18 javascript/packages/browser/build/libherb.js
-rw-r--r--@ 1 marcoroth  staff   365K Jan 17 11:18 javascript/packages/node-wasm/build/libherb.js

@pkg-pr-new

pkg-pr-new Bot commented Jan 17, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1075
npx https://pkg.pr.new/@herb-tools/language-server@1075
npx https://pkg.pr.new/@herb-tools/linter@1075

commit: c3f5fbc

@github-actions

github-actions Bot commented Jan 17, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit c3f5fbc


✅ Preview deployment has been cleaned up.

@marcoroth
marcoroth marked this pull request as ready for review January 17, 2026 10:13
@marcoroth
marcoroth merged commit 49017f7 into main Jan 17, 2026
20 checks passed
@marcoroth
marcoroth deleted the wasm-build-optimizations branch January 17, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant