跪拜 Guibai
← All articles
Frontend

The 20x Rust Build Speedup That Turned Into a Debugging Marathon

By 涛涛ing ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Teams chasing 20x build speedups must budget for stricter parsers, unfamiliar error stacks, and plugin rewrites; a single two-day debugging session or one week rewriting a loader can wipe out months of saved wait time.

Summary

Rspack's migration delivered on paper: cold start dropped from 45 seconds to 2, HMR went from seconds to milliseconds, and the official benchmark claimed roughly 20x. Within a week the build failed on a missing space in an old `@media` rule. Lightning CSS, which replaced Webpack's tolerant minifier, rejected it as invalid syntax. A dynamic import silently broke when CommonJS `default` export resolution shifted under stricter interop rules. Webpack had held together years of 'historical dust'; Rust tools refuse to.

The trade-off goes beyond strictness. Rust tools speed up execution of existing compilation burden, but they don't remove any of it: duplicate polyfills, dead tree-shaking, conflicting plugins, and unused loaders still run, just faster. Error stacks are less friendly, and a custom loader that survived five years in Webpack may have no Rspack equivalent, forcing a rewrite. Vite 8's Rolldown upgrade shows the same pattern: `/@/` aliases fail in config loaders, `manualChunks` object syntax is dropped, and Rollup hooks go unsupported.

The decision rule is greenfield or computation-bound. If the build spends 80% of its time compiling a huge library in `node_modules`, Rust pays off. If the repo is full of configs that work without explanation or nobody understands the build chain, the migration bill will eat the speed gain. Rustification is irreversible, but migration cost is the wall between a faster tool and a better project.

Takeaways
— Cold start build time fell from 45 seconds to 2 seconds after switching from Webpack to Rspack.
— HMR latency dropped from seconds to milliseconds.
— Lightning CSS rejects `@media and(max-width: 768px)` as invalid because of a missing space, failing the build.
— Rspack's stricter CommonJS interop changes `default` export resolution, causing silent dynamic import failures.
— Rust tool error stacks are less friendly than JavaScript tools and require a learning curve for complex debugging.
— A custom loader that worked in Webpack for five years may have no Rspack equivalent, forcing a rewrite or new plugin.
— Vite 8's Rolldown upgrade breaks `/@/` path aliases in config loaders, deprecates `manualChunks` object syntax, and drops some Rollup hooks and legacy plugins.
— Symptom-level optimizations like image compression and lazy loading account for under 20% of large project performance; architecture, loading strategy, and build chain redundancy dominate.
— Switch to Rust tools when the project is greenfield or when profiling shows 80% of build time goes to compiling a huge library in `node_modules`.
Conclusions

The speedup measures execution time, not total engineering time; when debugging and plugin rewrites are added, a 20x build improvement can become net-negative for a team that doesn't understand its build chain.

The binary advice (switch for new or computation-bound projects, postpone for legacy) underestimates the common case where a project has both historical debt and heavy computation; cleaning debt first is the only way Rust speedups become real.

Webpack's tolerance for invalid syntax and quirky interop was a feature that let teams accumulate debt; Rust tools turn that debt into hard failures, which is why migration cost is proportional to a project's age and historical sloppiness.

Concepts & terms
Rspack
A Rust-based bundler designed as a drop-in replacement for Webpack, offering faster builds by using a compiled language for the core compilation pipeline.
Rolldown
A Rust port of Rollup that powers Vite 8, bringing order-of-magnitude performance gains but also stricter behavior and different API expectations.
Lightning CSS
A Rust-based CSS parser and transformer used by Rspack; it enforces strict syntax rules that Webpack's tolerant minifier ignored.
From the discussion

One position takes the article's caution to heart: a faster tool does not make the project better, and silent failures that raise no error are the scariest failure mode of all. A countervailing firsthand report describes a webpack-to-rspack migration finished quickly with Claude Code, one UMD compilation pitfall aside, with a massive speed gain. The split turns on whether the legacy codebase has accumulated enough tolerated invalid syntax to make the move a marathon or a sprint.

— Tooling speed and engineering quality are orthogonal — the 20x build speedup looks satisfying, but the migration's real cost surfaces later, not in the benchmark.
— Silent failures are the most dangerous failure mode; not throwing an error is scarier than a loud crash because years of tolerated invalid syntax break without warning.
— A smooth migration is attainable: one report finished the webpack-to-rspack switch in a single short session with AI assistance, striking only a UMD compilation pitfall.
— The contested ground: the article's debugging-marathon narrative versus a near-trivial same-week migration, with the difference hinging on how much interop debt and invalid syntax the legacy build had absorbed.
Featured comments
组合搭配函数

"A faster tool doesn't mean a better project" — that hits the point dead on. The 20x speed looks great to watch, but the real bill for the migration comes due afterward. That silent-failure stretch made me break out in a cold sweat; the scariest thing is when it doesn't even raise an error.

mannymu

I just finished migrating from webpack to rspack the day before yesterday. Got it done in a short while with Claude Code, only tripping over one UMD compilation pitfall. The speed is far too much better.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗