Skip to content

refactor(trie-router): trade registration speed for bundle size - #5238

Merged
usualoma merged 1 commit into
refactor/trie-router-reduce-bundle-sizefrom
refactor/trie-router-minimize-bundle-size
Aug 16, 2026
Merged

usualoma merged 1 commit into
refactor/trie-router-reduce-bundle-sizefrom
refactor/trie-router-minimize-bundle-size

Conversation

@usualoma

Copy link
Copy Markdown
Member

This is a follow-up to the previous TrieRouter bundle-size reduction.

Important

This PR intentionally trades approximately 5.5% slower route registration for a smaller bundle. Matching benchmarks showed no meaningful performance regression.

It further reduces the bundle size by storing pattern metadata on child nodes and simplifying the route-registration path.

TrieRouter bundle Before After Difference
Minified 3,064 B 2,793 B -271 B
Minified + gzip 1,533 B 1,458 B -75 B

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

@usualoma

Copy link
Copy Markdown
Member Author

Hi @yusukebe,

This change makes route registration approximately 5.5% slower, while our benchmarks show no regression in matching performance. For TrieRouter specifically, I think the 271-byte reduction is a worthwhile trade-off for Hono. Do you think this trade-off is acceptable?

@yusukebe

Copy link
Copy Markdown
Member

@usualoma

The code I wrote a long time ago is being cleaned up, haha!

For TrieRouter specifically, I think the 271-byte reduction is a worthwhile trade-off for Hono. Do you think this trade-off is acceptable?

Yes. File size reduction is the No.1 priority for TrieRouter.

Can you merge those PRs into #5236?

@usualoma
usualoma merged commit 6bfcb5c into refactor/trie-router-reduce-bundle-size Aug 16, 2026
2 checks passed
@usualoma
usualoma deleted the refactor/trie-router-minimize-bundle-size branch August 16, 2026 23:39
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.

2 participants