Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@swc/core

swc-project27.7mApache-2.01.10.9TypeScript support: included

Super-fast alternative for babel

swc, swcpack, babel, typescript, rust, webpack, tsc

readme

swc

Make the web (development) faster.

downloads (@swc/core) downloads (3rd party)

undefined GitHub release (latest SemVer)

GitHub code size in bytes node-current (scoped)

Discord

SWC (stands for Speedy Web Compiler) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and JavaScript at the same time. If you are using SWC from Rust, see rustdoc and for most users, your entry point for using the library will be parser.

Also, SWC tries to ensure that

If you select the latest version of each crates, it will work

for rust users.

MSRV of crates is currently 1.73.

To update all SWC crates you use, you can run curl https://raw.githubusercontent.com/swc-project/swc/main/scripts/update-all-swc-crates.sh | bash -s. This script will update all dependencies to the latest version and run cargo build to ensure that everything works. Note that you need

  • jq
  • cargo upgrade

command to run the script.


If you are using SWC from JavaScript, please refer to docs on the website.

Documentation

Check out the documentation in the website.

Features

Please see comparison with babel.

Performance

Please see benchmark results on the website.

Supporting swc

Sponsors

SWC is a community-driven project, and is maintained by a group of volunteers. If you'd like to help support the future of the project, please consider:

Contributing

See CONTRIBUTING.md. You may also find the architecture documentation useful (ARCHITECTURE.md).

License

SWC is primarily distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.

changelog

Changelog

[unreleased]

Bug Fixes

Documentation

  • (es/parallel) Improve document of Parallel (#9896) (9962c9c)

Features

  • (es/minifier) Print total size from minify-all example (#9897) (134000f)
  • (es/minifier) Compress foo ? num : 0 into num * !!foo (#9908) (ce22557)

Miscellaneous Tasks

  • (es/minifier) Print slow files from minify-all example (#9899) (2d87b89)

Performance

  • (es/minifier) Make character frequency analysis parallel (#9895) (ca2fd1e)
  • (es/minifier) Parallelize handling of class members (#9900) (ed74839)
  • (es/minifier) Adjust threshold for parallel char frequency calculation (#9901) (47ea8de)
  • (es/minifier) Do heavy operation only if required (#9902) (2687231)
  • (es/minifier) Cache var_or_default calls (#9909) (4a3be8d)
  • (es/minifier) Invert cache to be really a cache (#9910) (8bfb0e5)

[1.10.8] - 2025-01-19

Bug Fixes

  • (es/decorators) Fix init order of 2022-03 impl (#9760) (751a310)
  • (es/ts_strip) Handle ASI hazard in return statement (#9882) (121b5fe)
  • (typescript) Collect usages in extend clauses of classes and interfaces (#9893) (ef29ef6)

Features

  • (typescript) Check computed property names of ts signatures (#9867) (caed78a)

Performance

  • (bench) Run benchmark on a custom runner (#9877) (2d6f9a5)
  • (es/codegen) Remove needless allocations (#9890) (f230ff2)
  • (es/minifier) Make the first run of DCE more efficient (#9868) (7329824)
  • (es/minifier) Box VarUsageInfo of ProgramData (#9894) (fafd754)
  • (es/renamer) Use IndexSet for rename queue (#9866) (f404720)

Refactor

  • (es/minifier) Add a way to profile minifier for real-world inputs (#9881) (9657294)
  • (es/minifier) Use chili for minify-all example (#9885) (197f0bc)
  • (es/minifier) Make minify-all profilable (#9888) (fbad136)

[1.10.7] - 2025-01-10

Bug Fixes

  • (ci/publish) Do not tag stable if onlyNightly is on (#9863) (c0c6056)
  • (es/parser) Fix context of dynamic import type (#9852) (caa7f37)

Documentation

  • Update the link to the team (0fcdc31)

Features

  • (ts/fast-strip) Distinguish invalid vs unsupported (#9846) (5709bc2)

Testing

  • (parallel) Add test to debug segfault on windows x64 (#9857) (ae53a35)

Build

[1.10.6] - 2025-01-07

Performance

  • (es/minifier) Speed up merge_sequences_in_exprs by caching computation (#9843) (6e5632f)

[1.10.5] - 2025-01-07

Bug Fixes

  • (es/minifier) Fix minification of framer-motion by checking cons.termniates() (#9818) (512c91f)
  • (typescript) Fix wrong check for super class (#9822) (2307a4d)

Documentation

Features

Miscellaneous Tasks

  • (deps) Update dependency magic-string to v0.30.17 (#9794) (51595ae)

Performance

  • (atoms) Update hstr to optimize == of Atom (#9845) (584a0a0)
  • (es/lints) Configure a benchmark for ES lints (#9833) (734ec21)
  • (es/minifier) Improve parallelism and cache friendliness (#9813) (f8dff56)
  • (es/minifier) Introduce FastJsWord and FastId in swc_atoms (#9826) (ef0ec38)

Refactor

  • (es/lints) Cleanup & prepare using chili (#9838) (d47844b)

Build

[1.10.4] - 2024-12-30

Bug Fixes

  • Remove Caused by: 'failed to parse' from TS blank space (#9820) (aaeb0ab)

[1.10.3] - 2024-12-27

Bug Fixes

  • (es/codegen) Emit semicolon after using declarations (#9816) (556d924)

[1.10.2] - 2024-12-26

Bug Fixes

  • (es) Don't panic when wasm bytecheck faild (#9803) (c81be2e)
  • (es/parser) Do not parse empty stmt after using decl (#9798) (c2696db)

Documentation

[1.10.1] - 2024-12-09

Bug Fixes

  • (es/resolver) Fix wrong syntax context of vars with the same names as catch params (#9786) (5a44c6b)

Features

  • (es/transforms) Add module.outFileExtension (#9784) (e04c7b3)

[1.10.0] - 2024-12-04

Bug Fixes

  • (es/codegen) Use raw value for emitting JSX text (#9762) (b83c44f)
  • (es/compat) Fix marker for inlined helpers (#9776) (f54ec2c)
  • (es/minifier) Drop console in optional chainings (#9759) (39271ad)
  • (es/minifier) Do not inline into the exact LHS (#9777) (985977b)

Features

  • (es/minifier) Support preserve_annotations of terser (#9775) (6e1c9fd)
  • (typescript) Align isolatedDeclaration implementation with tsc (#9715) (0adad25)

Miscellaneous Tasks

  • (deps) Update dependency magic-string to v0.30.13 (#9747) (fa80a1e)
  • (deps) Update dependency magic-string to v0.30.14 (#9764) (6e46a8b)

Refactor

  • (estree/compat) Do not use nightly features (#9772) (0f12bbd)

[1.9.3] - 2024-11-22

Bug Fixes

  • (@swc/types) Tsc build file ignored by npm (#9754) (14a5c1e)
  • (es) Source map super(...args) calls in injected constructors (#9745) (35b0ca0)
  • (es/plugin) Migrate swc plugin new to use .cargo/config.toml (#9740) (4ffb21e)
  • (es/resolver) Ignore VarDecl with declare: true (#9734) (aa0f784)

Documentation

Features

Miscellaneous Tasks

Performance

  • (es/plugin) Make analyze_source_file lazy, again (#9732) (c1d12d6)

Refactor

  • (es/compat) Use special span instead of passing static_blocks_mark (#9725) (6ad0735)

[1.9.2] - 2024-11-11

Bug Fixes

Features

  • (es/codegen) Implement proper inline_script support (#9729) (e732a36)

[1.9.1] - 2024-11-06

Bug Fixes

[1.9.0] - 2024-11-06

Bug Fixes

  • (es/minifier) Avoid generating reserved mangling names (#9710) (b49317a)

Features

  • (typescript) Port deno isolatedDeclarations updates (#9712) (6194044)

Miscellaneous Tasks

  • (deps) Update rust crate is-macro to v0.3.7 (#9713) (d48e6e8)

[1.8.0] - 2024-11-04

Bug Fixes

  • (es/typescript) Handle multiline type parameters in async arrow functions (#9704) (c5ed19c)
  • (es/typescript) Handle ASI hazards in fast type strip (#9707) (c135f71)

Features

  • (es/plugin) Introduce manual-tokio-runtmie to swc crate (#9701) (97298c4)

Performance

  • (es/renamer) Modify parallel renaming threshold (#9706) (91a9106)

[1.7.42] - 2024-10-31

Bug Fixes

  • (es/generator) Fix code generation for break in nested while (#9684) (65872af)
  • (es/resolver) Skip resolving lowercase JSXIdentifiers (#9686) (6ed1715)
  • (es/types) Add jsc.experimental.keepImportAssertions to types (#9691) (4b4dcfa)

Features

  • (es/minifier) Optimize switch with side effect and termination tests (#9677) (7344a63)
  • (es/parser) Ability to get script's potential module errors (#9682) (2bbd1e8)

Miscellaneous Tasks

Performance

  • (visit) Introduce Pass API and adjust visitor APIs for it (#9680) (581aafb)

[1.7.40] - 2024-10-26

Bug Fixes

  • (bindings) Update napi to handle string with \0 (#9665) (8f45eaf)
  • (bindings/node) Add VisitTsPropertySignature (#9670) (715c42c)
  • (es/renamer) Check preserved in normal renaming mode (#9666) (87b4e10)
  • (typescript) Check whether the method is abstract when checking is_overload (#9678) (78500af)

Documentation

Miscellaneous Tasks

  • (deps) Update dependency swc-plugin-coverage-instrument to ^0.0.25 (#9676) (b8d255b)

[1.7.39] - 2024-10-22

Bug Fixes

  • (es/compat) Add missing visit children for destructuring (#9658) (32116a0)
  • (es/parser) Correct > and < when exit type context (#9653) (abffc07)
  • (es/proposal) Use tsc version of explicit resource management (#9585) (f735108)
  • (wasm-typescript) Fix option types of functions (#9662) (4cbe33c)

Features

  • (es/minifier) Implement optional catch binding (#9657) (f70b842)

Miscellaneous Tasks

  • (es/typescript) Improve enum comments and sourcemap (#9652) (31fe3b6)

[1.7.36] - 2024-10-15

Bug Fixes

  • (es) Run esnext transforms on esnext target (#9644) (8a19201)
  • (es/codegen) Emit space after div if rhs has leading comment (#9631) (f2be26e)
  • (es/lints) Correct the false positive error of TS2309 (#9635) (f74c1f3)
  • (es/minifier) Check type of assignment target before merging assignments (#9617) (4436621)

Features

  • (es) Introduce runPluginFirst for Wasm plugins (#9645) (3d3e434)
  • (es/minifier) Support unary negate in cast_to_number (#9642) (88a2186)

Miscellaneous Tasks

  • (deps) Update dependency magic-string to v0.30.12 (#9634) (085bc19)

[1.7.35] - 2024-10-10

Bug Fixes

  • (es/codegen) Fix source map so it works with Sentry (#9627) (9c90a73)
  • (es/minifier) Compress consecutive return statements properly (#9620) (8263da1)
  • (es/module) Allow TypeScript nodes for Rewriter (#9606) (4ee45ac)
  • (html/minifier) Fix HTML minifier TS types (#9615) (7b98bb5)

Features

  • (bindings/html) Accept Buffer|string instead of Buffer (#9625) (62edb36)
  • (es/testing) Parse test code as a Program instead of a Module (#9264) (166b858)
  • (es/testing) Parse test code as a Program instead of a Module (#9623) (bfea322)

Miscellaneous Tasks

Performance

  • (es/codegen) Reduce usage of tracing::instrument (#9604) (2f06fc5)
  • (es/transforms) Copy benchmarks from oxc (#9602) (24c3a0c)
  • (es/typescript) Reduce unnecessary visits (#9605) (866af6c)

Refactor

  • (es/typescript) Simplifying enum and namespace transforms (#9558) (2480bb0)

Build

[1.7.29] - 2024-10-01

Bug Fixes

  • (es/codegen) Emit .d.ts when using --out-file (#9582) (3d9d641)
  • (es/module) Fix jsc.paths using absolute paths with dots in a filename for an alias (#9595) (74e3d04)
  • (es/parser) Fix failure of TS instantiation followed by satisfies (#9583) (77900d8)

Features

  • (es) Add options to disable all esnext transforms and lints (#9597) (f2b0766)

Miscellaneous Tasks

[1.7.28] - 2024-09-24

Bug Fixes

  • (ast) Add archive(check_bytes) to all relevant AST types (#9574) (185d6f5)
  • (cli) Exclude non-files from get_files_list (#9560) (85cc2bd)
  • (es/codegen) Fix wrong sourcemap when there are new lines in tpl (#9578) (cf74382)
  • (es/compat) Skip getter and setter as FlowHelper function do (#9580) (14cfd70)
  • (es/minifier) Avoid decl name when mangle with eval (#9546) (e2242c4)
  • (es/minifier) Check variable type while optimizing += (#9575) (04016e9)
  • (es/module) Rewrite import specifier in type declaration (#9577) (fc0ba2a)
  • (plugin) Don't panic when ast byte not match (#9562) (c36871a)

Miscellaneous Tasks

Testing

[1.7.25] - 2024-09-11

Bug Fixes

  • (es/codegen) Ensure decorators are emitted first in TS paramters (#9545) (47ef38d)

Features

  • (es/common) Introduce pure Span and BytePos to handle #__PURE__ (#9539) (f63a481)

Miscellaneous Tasks

  • (bindings/node) Fix type definition (64ec111)

[1.7.24] - 2024-09-08

Bug Fixes

  • (es/compat) Handle label block in constructor (#9528) (c43dbad)
  • (es/decorator) Add support for private access expressions in legacy decorators (#9535) (62ed065)
  • (es/minifier) typeof class should be function (#9522) (c7fdd6b)
  • (es/minifier) Prevent removing side effects from accessing getter (#9530) (8513816)
  • (es/typescript) Handle enum in single statement (#9532) (84b0043)

[1.7.23] - 2024-09-02

Bug Fixes

Performance

  • (es/compat) Reimplement constructor transform (#9519) (4b85a92)

[1.7.22] - 2024-08-30

Bug Fixes

  • (es/minifier) Iterate object properties in reverse direction while inlining property access (#9507) (f584ef7)

[1.7.21] - 2024-08-28

Bug Fixes

[1.7.19] - 2024-08-28

Bug Fixes

  • (es/minifier) Track if a var is used with in (#9508) (7d6269e)

Features

Miscellaneous Tasks

  • (es/codegen) Bump minimum required swc_allocator version to 0.1.8 (#9492) (5258763)

Refactor

[1.7.17] - 2024-08-23

Bug Fixes

  • (ci) FIx pattern for actions/download-artifact (ac7bd31)
  • (es/minifier) Force rename synthesized identifiers (#9473) (c72b5f8)
  • (es/minifier) Mark LHS of for-in/of as update (#9474) (ac432c4)
  • (es/typescript) Correctly handle deep import chains (#9487) (50d70d3)
  • (es/typescript) Correctly handle ESM context (#9490) (fc0483c)
  • (html) Fix html binding (eefae1c)

Features

  • (bindings/html) Allow using lightningcss as minfiier (#9462) (74d6478)
  • (es/minifier) Drop more patterns with PURE marker (#9478) (ede1a52)

Miscellaneous Tasks

  • (html) Use binding_html_node instead of html_node (bdea5cb)
  • (html) Fix publish action (f30fd4f)

Performance

Refactor

  • (common) Simplify SyntaxContext and Mark (#9476) (4bee30a)

[1.7.14] - 2024-08-19

Bug Fixes

  • (common) Use SourceMap::adjust_mappings in correct order (#9447) (05961eb)

Features

  • (es/decorators) Groundwork for stage 3 decorator (#9450) (238ba8b)

Refactor

[1.7.12] - 2024-08-19

Bug Fixes

  • (common) Do not use adjust_mappings from sourcemap crate (#9437) (563c162)
  • (es) Mark TypeScript nodes as reachable from Evaluator (#9440) (308e5ec)
  • (es/compat) Init this in sub class constructor for async (#9446) (bfaf31b)
  • (es/decorators) Fix metadata for accessors (#9444) (99738ef)

Miscellaneous Tasks

  • (deps) Update rust crate arrayvec to v0.7.6 (#9436) (08dd948)

[1.7.11] - 2024-08-14

Bug Fixes

  • (es) Improve sourcemap url error messages. (#9422) (230d1d9)

Features

  • (es/typescript) Add native_class_properties to skip reordering of class properties inits (#9421) (d2929d1)
  • (estree/compat) Remove dependency on rayon (#9393) (34d1b27)
  • (html/minifier) Support using custom css minifier (#9425) (970cc81)

Miscellaneous Tasks

  • (es/preset-env) Update core js compat data (#9407) (ce761cf)
  • (es/typescript) Remove the workaround for wasm-bindgen (#9428) (55f7268)

[1.7.10] - 2024-08-09

Bug Fixes

  • (es/typescript) Strip optional mark and definite mark (#9411) (8c161a0)
  • (es/typescript) Strip exported default overload function declaration (#9412) (b395f48)
  • (es/typescript) Strip this param in getter/setter (#9414) (442fb7b)
  • (es/typescript) Update ts-strip type definition (#9415) (165c8fa)

[1.7.9] - 2024-08-09

Bug Fixes

[1.7.8] - 2024-08-09

Bug Fixes

  • (common) Do not generate invalid source map (#9050) (9d65c77)
  • (common) Require newer version of allocator (#9386) (4e854c7)
  • (es/module) Drop the level of a few tracing events (#9380) (95af253)
  • (es/typescript) Enable Injector to process JSX (#9395) (e24e2ff)
  • (es/typescript) Strip declaration of exported function overloads (#9397) (5c8aa52)

Features

  • (visit) Make kind() accessible without swc_visit (#9382) (021e41d)

Miscellaneous Tasks

  • (es/typescript) Remove unreachable_visit_mut_type (#9390) (8e49c90)

Testing

  • (es/typescript) Verify TypeScript stripped output (#9398) (4c4c860)

[1.7.6] - 2024-08-04

Bug Fixes

  • (es/codegen) Print the missing abstract in class expression (#9372) (c2e3021)
  • (es/decorators) Use correct class name reference (#9375) (badd6a9)
  • (es/typescript) Strip declare export in strip-only mode (#9374) (c53cce4)

[1.7.5] - 2024-08-02

Bug Fixes

  • (es/parser) Fix span for unterminated block comments (#9361) (dc1b87e)
  • (es/parser) Make UnterminatedBlockComment stick to the EOF (#9366) (4f0fc6e)
  • (es/typescript) Handle single type statement in if/for/while (#9364) (2217730)
  • (es/typescript) Handle backtick in ASI issue (#9367) (6f1716c)

Miscellaneous Tasks

  • (deps) Update rust crate toml to v0.8.19 (#9360) (9cd51ce)

[1.7.4] - 2024-07-31

Bug Fixes

  • (es/codegen) Emit question token for class methods (#9342) (636585b)
  • (es/minifier) Preserve flags while dropping elements of SeqExpr (#8907) (24e8798)
  • (es/typescript) Fix ASI in expression for fast strip (#9358) (3ee82e2)

Documentation

  • (contributing) Add warning for test --all (#9338) (234bb97)

Miscellaneous Tasks

  • (deps) Update rust crate toml to v0.8.16 (#9327) (67aadfa)
  • (deps) Update dependency magic-string to v0.30.11 (#9345) (ced06e2)
  • (deps) Update rust crate toml to v0.8.17 (#9349) (d5472cc)

[1.7.3] - 2024-07-27

Bug Fixes

  • (es/decorators) Fix TypeScript syntax assertion (#9336) (acb3952)

[1.7.2] - 2024-07-25

Bug Fixes

  • (es/ast) Accept any case of EsVersion during deserialization (#9329) (56da6be)
  • (es/typescrupt) Fix ASI issue in fast ts strip (#9332) (57146cf)

Documentation

  • (bindings/wasm) Document supported TypeScript version (#9334) (66f31c0)

[1.7.1] - 2024-07-24

Bug Fixes

  • (bindings/types) Add missing mangle options (#9298) (567f40d)
  • (es/ast) Make span of binding ident include type ann (#9293) (2b32481)
  • (es/typescript) Preserve type assertions (#9328) (4d60f52)
  • (es/utils) Use $crate for quote_ident!() (#9309) (bdaaf47)

Features

  • (allocator) Feature gate nightly via macros (#9274) (a31fb58)
  • (es/typescript) Add esm build for fast ts strip (#9286) (d10cb9f)

Miscellaneous Tasks

  • (deps) Update wasmer to fix broken Windows build (#9322) (a120faf)

Performance

  • (allocator) Use std instead of allocator-api2 (#9281) (88723db)
  • (es/codegen) Use Vec<T> from swc_allocator (#9280) (c1cd0b9)
  • (es/codegen) Optimize using swc_allocator (#9294) (07376c6)
  • (es/helpers) Use bool instead of AtomicBool (#9321) (8107e98)

Refactor

Build

[1.7.0] - 2024-07-18

Bug Fixes

  • (allocator) Fix allocator & add benchmark (#9234) (037dad5)
  • (allocator) Remove wrong assertions and add tests (#9252) (d8e8b04)
  • (es/codegen) Fix codegen of large numeric literals (#9226) (fba79e6)
  • (es/compat) Consider only the variables used in the closure (#9151) (1357531)
  • (es/compat) Add support for destructuring with BigInts (#9215) (2cc7028)
  • (es/minifier) Fix variable declaration in default branch (#9220) (a7c82bd)
  • (es/minifier) Check this in function params (#9229) (da4866d)
  • (es/minifier) Remove optimization for array pattern (#9241) (521161e)
  • (es/minifier) Fix panic in bitwise logic and incorrect values (#9258) (baeb9e2)
  • (es/minifier) Collect raw str values for new Tpl element (#9261) (6ddbfa0)
  • (es/typescript) Handle unicode for fast ts strip (#9202) (096bfe3)

Documentation

  • (allocator) Mention oxc_allocator (be99ce0)
  • (contributing) Fix deno installation url (#9249) (ff5bbda)
  • (es/minifier) Add contributing section (e22f3ba)

Features

  • (es/typescript) Add transform mode back to fast TS strip (#9237) (8231e3c)
  • (es/utils) Support for arrays using cast_to_number (#9212) (2aef14d)

Miscellaneous Tasks

  • (es/typescript) Improve decorator handling of fast strip (#9178) (962170f)

Performance

  • (bindings/wasm) Shrink the size of the wasm file (#9191) (3a23b3d)
  • (es/typescript) Add a benchmark for fast TS strip (#9205) (7d9364c)
  • (es/visit) Introduce standard_only_* macros (#9207) (92879b1)

Refactor

  • (allocator) Use & instead of a thread-local (#9235) (8d5670e)
  • (allocator) Use RAII guard instead of scope (#9254) (6e098ae)
  • (common) Drop SyntaxContext from AST nodes (#9175) (b2491e5)
  • (es) Use Into and From for AST construction (#9201) (0960b23)

Testing

Pers

[1.6.13] - 2024-07-06

Bug Fixes

Features

Testing

[1.6.12] - 2024-07-06

Bug Fixes

  • (es/decorators) Fix bugs of 2022-03 implementation (#9145) (8a3ae44)
  • (es/loader) Exclude .json from default extension list (#9134) (e94e5e7)
  • (es/renamer) Fix renaming of default-exported declarations (#9135) (45f671d)
  • (es/typescript) Fix tricky cases in TS fast strip (#9159) (2bc51b8)
  • (es/typescript) Fix replacement logic of fast TS strip (#9163) (c5acafe)

Features

  • (bindings/ts) Add transform/strip-only mode (#9138) (a08bb46)
  • (es/testing) Improve comment testing story (#9150) (3638e97)
  • (es/typescript) Improve fast TS stripper (#9152) (9fca4ab)
  • (es/typescript) Improve fast TS stripper (#9153) (732d748)

Performance

  • (es) Reduce allocations for dynamic stacks (#9133) (648830a)

Refactor

  • (bindings/ts) Inline Wasm file into wasm.js (#9139) (307b6f2)

[1.6.7] - 2024-07-03

Refactor

  • (es/typescript) Extract type annotation proposal out (#9127) (dfee5f8)

Testing

Build

  • (bindings) Fix build of typescript binding (#9125) (f409bc0)