LinuxCommandLibrary

swc

Fast Rust-based JavaScript and TypeScript compiler

TLDR

Compile file

$ swc [input.js] -o [output.js]
copy
Compile directory
$ swc [src/] -d [dist/]
copy
Watch mode
$ swc [src/] -d [dist/] -w
copy
With source maps
$ swc [input.js] -o [output.js] --source-maps
copy
Use config file
$ swc [input.js] -o [output.js] --config-file [.swcrc]
copy

SYNOPSIS

swc [-o output] [-d dir] [-w] [options] input

DESCRIPTION

swc (Speedy Web Compiler) is a JavaScript and TypeScript compiler written in Rust, designed as a significantly faster alternative to Babel. It handles transpilation, JSX transformation, TypeScript stripping, and minification in a single tool.
The compiler supports modern JavaScript features, downlevel compilation to older targets, and React JSX transformation. TypeScript files are compiled by stripping types without performing type checking, making it much faster than tsc for builds where type checking is handled separately.
SWC can process individual files, entire directories with watch mode for development, and generates source maps for debugging. It is used as the compilation engine by tools like Next.js and Parcel.

PARAMETERS

-o FILE

Output file.
-d DIR
Output directory.
-w
Watch mode.
--source-maps
Generate source maps.
--config-file FILE
Configuration file.
--sync
Synchronous mode.

CONFIGURATION

.swcrc

Project configuration file in JSON format defining compilation target, module type, JSX settings, and minification options.

CAVEATS

Less plugins than Babel. Rust ecosystem. Config differs from Babel.

HISTORY

SWC (Speedy Web Compiler) was created by Donny as a fast JavaScript/TypeScript compiler written in Rust.

SEE ALSO

babel(1), tsc(1), esbuild(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community