swc-project/swc
Rust-based platform for the Web
Rust-based JavaScript/TypeScript compiler and minifier platform for high-performance web tooling
Source code flows through parsing, transformation, and code generation stages, with configuration controlling behavior at each step
Under the hood, the system uses 1 feedback loop, 2 data pools, 2 control points to manage its runtime behavior.
Structural Verdict
A 10-component fullstack with 7 connections. 42837 files analyzed. Well-connected — clear data flow between components.
How Data Flows Through the System
Source code flows through parsing, transformation, and code generation stages, with configuration controlling behavior at each step
- Source Input — JavaScript/TypeScript/HTML source code accepted as string or Buffer
- Parse — Source parsed into AST using syntax-aware lexer with TypeScript/JSX support
- Transform — AST transformed using configured plugins and target compatibility settings
- Minify — Optional minification with compression, mangling, and format options
- Codegen — Generate final JavaScript/CSS/HTML output with sourcemaps
System Behavior
How the system actually operates at runtime — where data accumulates, what loops, what waits, and what controls what.
Data Pools
Shared source map instance across all compilation operations
Parsed abstract syntax trees for transformation pipeline
Feedback Loops
- Error Recovery (retry, balancing) — Trigger: Parse or transform errors. Action: Attempts graceful error recovery and continues processing. Exit: Successful recovery or fatal error.
Delays & Async Processing
- Native Module Loading (async-processing) — Platform-specific native binary loading on first use
- WASM Initialization (async-processing) — WebAssembly module compilation and instantiation
Control Points
- SWC_DEBUG (env-var) — Controls: Debug logging and panic backtrace collection
- Target Syntax (runtime-toggle) — Controls: JavaScript/TypeScript parsing mode and feature support
Package Structure
This monorepo contains 10 packages:
Main JavaScript/TypeScript compiler with parsing, transformations, and bundling functionality
Runtime helper functions for transformed JavaScript code (e.g., class inheritance, async/await polyfills)
HTML parsing and minification capabilities
JavaScript minification and optimization tooling
React-specific compilation and optimization features
TypeScript definitions for SWC configuration and API interfaces
Node.js native binding for core SWC functionality via NAPI
WebAssembly binding for core SWC functionality for browser/universal usage
Node.js native binding for HTML processing functionality
Command-line interface for SWC compilation and transformation
Technology Stack
Core compiler implementation and performance-critical parsing
Node.js native binding generation
WebAssembly binding generation
Type definitions and package APIs
Workspace management and package building
JavaScript testing framework
Additional testing for specific packages
Key Components
- COMPILER (service) — Singleton Rust compiler instance with shared SourceMap for all transformations
bindings/binding_core_node/src/lib.rs - JsCompiler (class) — NAPI-exposed JavaScript wrapper for the Rust compiler
bindings/binding_core_node/src/lib.rs - minify (function) — JavaScript minification API with sync and async variants
packages/minifier/src/index.ts - minifyDocument (function) — HTML document minification with CSS/JS optimization
bindings/binding_html_node/src/lib.rs - parse (function) — JavaScript/TypeScript parser that returns AST and tokens for analysis
bindings/binding_es_ast_viewer/src/lib.rs - isReactCompilerRequired (function) — Analyzes code to determine if React compiler optimizations should be applied
packages/react-compiler/src/index.ts - _class_check_private_static_access (utility) — Runtime helper for private static field access validation in classes
packages/helpers/esm/_class_check_private_static_access.js - Parser (class) — ECMAScript/TypeScript parser with syntax-aware lexing
bindings/binding_es_ast_viewer/src/lib.rs - MinifyTask (class) — Async task structure for HTML minification operations
bindings/binding_html_node/src/lib.rs - JsMinifyOptions (type-def) — TypeScript definitions for JavaScript minification configuration
packages/types/index.ts
Sub-Modules
Main JavaScript/TypeScript compilation pipeline with transformations
HTML parsing and minification with CSS/JS optimization
Standalone JavaScript minification and optimization
Command-line interface for SWC compilation and processing
Configuration
sgconfig.yml (yaml)
ruleDirs(array, unknown) — default: rules
tests.yml (yaml)
os.windows(array, unknown) — default: swc,swc_allocator,swc_cli,swc_common,swc_css_codegen,swc_css_parser,swc_ecma_codegen,swc_ecma_loader,swc_ecma_parser,swc_ecma_preset_env,swc_ecma_transforms_module,swc_ecma_transforms_testing,swc_html_codegen,swc_html_parser,swc_node_bundler,swc_plugin,swc_plugin_backend_wasmer,swc_plugin_testingos.macos(array, unknown) — default: swc,swc_allocator,swc_plugin_backend_wasmercheck.swc(array, unknown) — default: cargo hack check --feature-powerset --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest --exclude-features plugin_transform_host_js --exclude-features plugin_backend_wasmer --features par-core/chilicheck.swc_allocator(array, unknown) — default: cargo hack check --feature-powersetcheck.swc_bundler(array, unknown) — default: cargo hack check --feature-powersetcheck.swc_common(array, unknown) — default: cargo hack check --feature-powerset --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features rkyv-implcheck.swc_ecma_ast(array, unknown) — default: cargo hack check --feature-powerset --exclude-features __rkyvcheck.swc_ecma_loader(array, unknown) — default: cargo hack check --feature-powerset- +7 more parameters
cspell.json (json)
version(string, unknown) — default: 0.2language(string, unknown) — default: enallowCompoundWords(boolean, unknown) — default: truewords(array, unknown) — default: aarch,ahash,anonymized,ANONYMIZED,ansi,Ansi,armv,arrayvec,ascii,babelify,Babelify,bools,bors,bpos,BUILTINS,canonicalization,canonicalize,chpos,clippy,cmpeq,cmplt,cmts,Cmyk,cname,combinator,Combinator,compiliation,cond,Cond,conds,constness,consts,corejs,creduce,crev,ctxt,ctxts,declarators,dedup,deduped,dejavu,delim,Delim,deno,Deno,deps,Deque,Deser,deserialization,docsrs,dont,DWORD,ecma,ecmascript,eddyb,elems,esbuild,esmodule,esms,esnext,estree,eval,Eval,exponentiation,fargs,finalizer,fnames,fract,gnueabihf,hasher,idents,iife,impls,indexmap,initializers,inlinable,inlines,instanceof,interner,intrinsics,ints,jsdoc,jsonify,jsxs,jszip,kaios,keyof,linebpos,linechpos,loadu,LPCSTR,LPSECURITY,mbcs,memchr,miette,Miette,mimalloc,minifier,miri,misdesigned,mkdir,msvc,napi,nncs,noinline,NOINLINE,optimizable,paren,Paren,plotly,pmutil,pointee,prec,PREC,proto,proxied,punct,putc,qself,RAII,reconsume,regs,repr,rfind,rkyv,rmatch,rplugin,rpos,rposition,rsplit,rustc,sabi,seqs,sess,shopify,skippable,smallvec,spanx,stmts,succ,sugg,swcify,swcpack,swcrc,systemjs,termcolor,typeofs,uncons,Unexported,Unexporter,unignore,unimpl,unsafes,untrusted,variadic,vercelflagWords(array, unknown) — default: actally
renovate.json (json)
$schema(string, unknown) — default: https://docs.renovatebot.com/renovate-schema.jsonextends(array, unknown) — default: config:recommendedautomergeStrategy(string, unknown) — default: squashautomergeType(string, unknown) — default: prpackageRules(array, unknown) — default: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]ignorePaths(array, unknown) — default: packages/core/e2e/fixtures
Explore the interactive analysis
See the full architecture map, data flow, and code patterns visualization.
Analyze on CodeSeaRelated Fullstack Repositories
Frequently Asked Questions
What is swc used for?
Rust-based JavaScript/TypeScript compiler and minifier platform for high-performance web tooling swc-project/swc is a 10-component fullstack written in Rust. Well-connected — clear data flow between components. The codebase contains 42837 files.
How is swc architected?
swc is organized into 4 architecture layers: Rust Core Libraries, Native Bindings, npm Packages, Platform-Specific Natives. Well-connected — clear data flow between components. This layered structure enables tight integration between components.
How does data flow through swc?
Data moves through 5 stages: Source Input → Parse → Transform → Minify → Codegen. Source code flows through parsing, transformation, and code generation stages, with configuration controlling behavior at each step This pipeline design reflects a complex multi-stage processing system.
What technologies does swc use?
The core stack includes Rust (Core compiler implementation and performance-critical parsing), NAPI-RS (Node.js native binding generation), wasm-bindgen (WebAssembly binding generation), TypeScript (Type definitions and package APIs), Yarn (Workspace management and package building), Jest (JavaScript testing framework), and 1 more. A focused set of dependencies that keeps the build manageable.
What system dynamics does swc have?
swc exhibits 2 data pools (SourceMap Cache, AST Pool), 1 feedback loop, 2 control points, 2 delays. The feedback loops handle retry. These runtime behaviors shape how the system responds to load, failures, and configuration changes.
What design patterns does swc use?
5 design patterns detected: Native Binding Pattern, Platform-Specific Packages, Singleton Compiler, Task-based Async, Helper Function Export.
Analyzed on March 31, 2026 by CodeSea. Written by Karolina Sarna.