Skip to content

🧼 split layout and input entrypoints#37

Open
natemoo-re wants to merge 2 commits into
ref/optfrom
ref/opt-split
Open

🧼 split layout and input entrypoints#37
natemoo-re wants to merge 2 commits into
ref/optfrom
ref/opt-split

Conversation

@natemoo-re
Copy link
Copy Markdown
Member

@natemoo-re natemoo-re commented May 23, 2026

Building on #35, this PR further reduces npm install size by ~23% (113 kB → 87 kB unpacked) and enables per-consumer DCE via:

  • splits the WASM compilation into two scoped modules: module-layout.c (Clay engine + ANSI renderer) and module-input.c (trie + input state machine)
    • new ./layout (57 kB) and ./input (28 kB) export subpaths via build-npm.ts, enabling bundler DCE for downstream consumers
    • both WASM files together land at 38 kB — 40% smaller than the unified WASM (~64 kB). Some shared code (mem, utf8) is duplicated across both, but negligible in practice.
    • why does splitting decrease the overall size? Narrower C compilation targets allow the linker's --gc-sections to use more aggressive DCE, which then passes to wasm-opt for further savings
  • removed unified wasm.ts and updated .gitignore and Makefile clean targets accordingly

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/clayterm@37

commit: 31d049e

@natemoo-re natemoo-re changed the title ref(wasm): split layout and input entrypoints 🧼 split layout and input entrypoints May 23, 2026
Copy link
Copy Markdown

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

There are quite a few references to both wasm.ts and clayterm.wasm still

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