@swc/core
SWC (Speedy Web Compiler) is a Rust-based JavaScript/TypeScript compiler that provides a drop-in replacement for Babel with dramatically faster compilation spee…
Installation
npm install -D @swc/core
yarn add -D @swc/core
pnpm add -D @swc/core
Import
import { transform } from '@swc/core';Quick Example
import { transformSync } from '@swc/core';
const output = transformSync('const x: number = 1;', {
jsc: {
parser: { syntax: 'typescript' },
target: 'es2020',
},
});
console.log(output.code);About @swc/core
SWC (Speedy Web Compiler) is a Rust-based JavaScript/TypeScript compiler that provides a drop-in replacement for Babel with dramatically faster compilation speeds. SWC can parse, transform, and minify JavaScript and TypeScript code 20-70x faster than Babel by leveraging Rust's performance characteristics and efficient memory management. The compiler supports all modern JavaScript features, TypeScript, JSX/TSX, decorators (both legacy and stage 3), and common Babel plugins including module transforms, dead code elimination, and polyfill injection. SWC's minifier (swc-minify) provides an alternative to Terser with comparable output quality at significantly faster speeds. The compiler integrates with build tools through @swc/core for programmatic usage, swc-loader for Webpack, @swc/jest for Jest, and is used internally by Next.js and Parcel as their default TypeScript/JavaScript compiler. SWC also provides a bundler (swcpack) that aims to be a Webpack alternative, though it is still experimental. SWC's speed makes it particularly impactful in large codebases where Babel compilation times become a significant bottleneck during development and CI builds.
Quick Facts
| Package | @swc/core |
| Category | Build Tool |
| Weekly Downloads | 10M+ |
| License | Apache-2.0 |
| Install | npm install -D @swc/core |
Related Packages
Babel is the standard JavaScript compiler that transforms modern JavaScript and TypeScript syntax in…
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type de…
Vite is a next-generation frontend build tool created by Evan You (creator of Vue.js) that provides …
Next.js is the leading React framework for building full-stack web applications, developed and maint…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.