Sucrase describes itself as a "super-fast Babel alternative" targeting development builds. By making some restrictive assumptions, Sucrase may achieve significant speed gains vs. Babel. Developers may evaluate the speed gain on Sucrase's website by supplying TypeScript code and observing both results of Sucrase and Babel compilers. The default example shows speed gains varying between a 4-time and 7-time speed gain on a 20 line-of-code source. Sucrase provides in its GitHub project the example of a large TypeScript codebase with 661K lines of code, which Sucrase compiled 20-times faster than Babel:
The observed speed gains are achieved by a reduction in scope of the compiler goals, and an architecture sacrificing maintainability for performance. Sucrase explains the scope reduction as follows:
Instead of compiling a large range of JS features to be able to work in Internet Explorer, Sucrase assumes that you're developing with a recent browser or recent Node.js version, so it focuses on compiling non-standard language extensions: JSX, TypeScript, and Flow.
Specific transforms are also included to deal with ES Modules (
export) and development with React (
Architecture-wise, Sucrase's syntax tree transforms are intricately coupled for better performance. As a result, Sucrase does not support plugins and is hard to extend with new language extensions and upcoming language features.
Sucrase seeks to provide a better developer experience, specially on large codebases, where build times can be slow, and the caches used to remediate that problem may themselves be fragile, occasionally requiring a slow clean build. The problem is specially acute for testing, which is a highly iterative process, and may benefit from improved compilation cycles.
Sucrase does not however intend to be a replacement for Babel. The documentation mentions:
You should think carefully before using Sucrase in production. Sucrase is mostly beneficial in development, and in many cases, Babel or tsc will be more suitable for production builds.
Sucrase is MIT-licensed. A large part of Sucrase is based on a fork of the Babel parser, which is also MIT-licensed. Contributions are welcome, whether in the form of bug reports, pull requests, documentation, or tests. Contributions must follow the Contributing Guide.