I’m working on a project using Vite, and I want to understand the difference between using TypeScript alone and TypeScript with SWC. I’ve searched online but couldn’t find a clear explanation. I believe it would be helpful to get answers from experienced developers, which is why I’m asking here. Could someone explain the differences and when it’s better to use one over the other?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
3
Answers
The + SWC options use SWC for transpilation instead of Babel, which is generally faster than the non-SWC option, but might (in rare cases) have bugs. (For React, this really means whether to choose this or this Vite plugin.)
I would select a + SWC option.
SWC is a compiler/transpiler and bundler for Javascript/Typescript, generally it’s faster than other options like babel, tsc, esbuild. SWC website: SWC
The Vite projects using
Typescript
option use Babel, and usingTypescript + SWC
option use SWC.SWC
Advantages:
Disadvantages:
Project Types:
Babel
Advantages:
Disadvantages:
Project Types:
A resume of differences between Babel and SWC according to my point of view and what I understood.
Sources: