swc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSWC
SWC
SWC (Speedy Web Compiler) is a Rust-based extensible platform. It is the compiler inside Next.js and Deno.
SWC(Speedy Web Compiler)是一个基于Rust的可扩展平台,是Next.js和Deno内置的编译器。
When to Use
使用场景
- Compilation: Replacing Babel.
- Minification: Faster and often smaller than Terser.
- Jest: speeds up tests by 10x.
@swc/jest
- 编译:替代Babel。
- 代码压缩:比Terser更快,生成的文件通常更小。
- Jest测试:可将测试速度提升10倍。
@swc/jest
Core Concepts
核心概念
Transforms
转换
Supports standard transforms (React JSX, TypeScript, legacy decorators).
支持标准转换(React JSX、TypeScript、旧版装饰器)。
Plugins (Wasm)
插件(Wasm)
SWC plugins are written in Rust (Wasm), making them fast but harder to write than Babel plugins.
SWC插件使用Rust(Wasm)编写,速度很快,但比Babel插件更难开发。
Best Practices (2025)
2025年最佳实践
Do:
- Use : In Webpack configs.
swc-loader - Use : JSON configuration file (similar to
.swcrc)..babelrc
Don't:
- Don't stick with Babel: Unless you need a very niche Babel plugin that doesn't exist in SWC yet.
推荐做法:
- 使用:在Webpack配置中使用。
swc-loader - 使用:JSON配置文件(类似
.swcrc)。.babelrc
不推荐做法:
- 不要固守Babel:除非你需要某个SWC尚未支持的非常小众的Babel插件。