swift·rust
All posts
compilerswcperformance

Inside the SWC plugin

How we turned a 200-millisecond build into a 12-millisecond build.

Jordan Kim··11 min read

The single biggest performance win in the framework is the SWC plugin. It runs at build time, and it does three things:

1. Strips "use client" / "use server" directives and replaces them with virtual modules. 2. Collects imports for the bundler, so it knows exactly what to ship. 3. Emits error codes (SR-E0001 through SR-E1404) for common mistakes, so the dev server can show you a friendly error message instead of a stack trace.

The plugin is powered with Rust and uses swc_core. It compiles in about a second, and it runs in about 12 milliseconds per file. That is the difference between a 200-millisecond incremental build and a 12-millisecond one.