Skip to content

Conversation

@kddnewton
Copy link
Collaborator

No description provided.

@kddnewton kddnewton merged commit 26b745f into main Dec 22, 2025
64 checks passed
@kddnewton kddnewton deleted the reduce-wasm-size branch December 22, 2025 15:09
@enebo
Copy link
Collaborator

enebo commented Dec 22, 2025

@kddnewton Awesome. All of these settings I believe also are the same to allow the parser implementation work compiled with Chicory (from what I recall).

marcoroth added a commit to marcoroth/herb that referenced this pull request Jan 17, 2026
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>
<summary>Details</summary>

**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
```

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants