Back to browse
Kdts, an optimization-first TypeScript compiler

Kdts, an optimization-first TypeScript compiler

by szaglam·Apr 22, 2026·2 points·0 comments

AI Analysis

●●SolidBig BrainNiche Gem

TypeScript compiler using Google Closure Compiler for type-driven size optimizations.

Strengths
  • Google Closure Compiler backend enables aggressive type-driven tree shaking.
  • Fast mode wraps bun build for compatibility with existing workflows.
  • Achieves 40% smaller output on typed codebases compared to standard bundlers.
Weaknesses
  • Bun-only runtime support limits adoption in Node-heavy ecosystems.
  • Opt mode requires strict typing subset, blocking gradual migration.
Target Audience

Frontend engineers optimizing bundle size

Similar To

esbuild · Google Closure Compiler · swc

Post Description

kdts is an optimization-first TypeScript compiler. Instead of erasing types as early as possible, it uses them throughout the compilation to direct optimizations, achieving transformations that would not have been possible were the types not known.

Currently it is Bun-only. You can install it with

bun add -g @kimlikdao/kdts

It has two modes: fast and opt.

- fast mode is a thin wrapper around bun build but supports the same command line arguments as opt mode.

- opt mode uses (a fork of) Google Closure Compiler as a backend to perform type-driven optimizations.

Fast mode should work on most valid TypeScript programs:

kdts entry.ts --fast

In opt mode, the sources need to be accurately typed and written in a small but expressive subset of TypeScript for now. Such programs can be compiled with

kdts entry.ts

It currently compiles our kimlikdao-lib in opt mode, including substantial cryptography and decentralized identity code.

I built kdts while working on kimlikdao-lib, where type-driven optimizations seemed very useful, but writing code for Closure Compiler directly was painful and never seemed to get easier. kdts lets you write code in idiomatic TypeScript while still targeting Closure Compiler for aggressive optimization.

kdts is still under active development, but it is already useful for us on kimlikdao-lib. I’m interested in hearing from others who have codebases where this kind of type-driven optimization could be useful, and what features or workflow support would matter most for adoption.

Similar Projects

AI/ML●●Solid

Profine – optimize your PyTorch training script before the run

Automated PyTorch optimizer delivering 3x speedups before you waste cloud credits.

Solve My ProblemBig Brain
aisinghal
301mo ago