# ts-node vs SWC: CIでTypeScriptをより速く実行する

> ts-node vs SWC register (CI): tscベースの実行 vs Rust速度のトランスパイル、type checking、ESM。CIスクリプトを速く保つTypeScript runnerはどちらか。

Source: https://latchkey.dev/ja/learn/tool-comparisons/ts-node-vs-swc-node  
Updated: 2026-06-26

ts-nodeはtscを通じてTypeScriptを実行します。SWC register(または@swc-node)と組み合わせると、Rust速度のトランスパイルに切り替わり、実行がはるかに速くなります。

ts-nodeはTypeScriptコンパイラ経由でTypeScriptを実行します。SWCのアプローチ(ts-nodeの--swcフラグまたは@swc-node/register)はRustのSWCでトランスパイルし、起動をはるかに高速にしますが、実行中の完全なtype-checkingは行わない代償があります。

## Comparison

|  | ts-node | SWC (register) |
| --- | --- | --- |
| トランスパイルエンジン | tsc | SWC (Rust) |
| 起動速度 | より遅い | はるかに高速 |
| Type checking | 任意(より遅い) | なし(除去のみ) |
| ESMサポート | 動作する(設定) | 動作する |
| 最適な用途 | 型を意識した実行 | スクリプト/テストの高速実行 |

## CIでは

素のts-nodeは実行しながらtype-checkできますが最も遅い選択肢です。SWC register(またはts-node --swc)を使うと同じworkflowを保ちながらはるかに速くトランスパイルでき、スクリプトとテストの起動を削減します。他の高速トランスパイラと同様、SWCはtype-checkしないため、tsc --noEmitを別途実行します。CIでの純粋な実行速度では、SWCの経路が勝ります。

## type-checkを分離する

SWCは型を除去するだけなので、型安全のためにtsc --noEmitステップ(並列)を追加します。どちらもmanaged runnerで動作し、高速なmanaged runnerは大きなコードベースでの長いtype-checkパスを短縮します。

## The switching cost is mostly in the parts nobody lists

- Assertions and mocks usually port mechanically when the target implements a compatible API; custom transformers and framework plugins do not.
- Snapshot formats differ between runners, so plan to regenerate and review rather than port.
- Run both suites in parallel in CI for a period and diff the results. A migration that changes which tests fail is not a migration, it is a regression you have not found yet.
- Coverage numbers move on a runner change even when the tests do not, because instrumentation differs. Re-baseline any coverage gate deliberately.

## 結論

TypeScriptの実行を最速にしたいなら: ts-nodeをSWC register(または@swc-node)とともに使い、別途のtsc --noEmitチェックを加える。型を意識した実行を1つのツールで必要とするなら: 素のts-node。ほとんどのpipelineは速度とtype-checkingを分けます。

## FAQ

### ts-node vs SWC: Running TypeScript Faster in CI?

ts-node executes TypeScript via the TypeScript compiler. The SWC approach (ts-node's --swc flag or @swc-node/register) transpiles with SWC in Rust for far faster startup, at the cost of not running full type-checking during execution.

### In CI?

Plain ts-node can type-check as it runs but is the slowest option; using the SWC register (or ts-node --swc) keeps the same workflow while transpiling far faster, which trims script and test startup. As with other fast transpilers, SWC does not type-check, so run tsc --noEmit separately. For sheer execution speed in CI, the SWC path wins.

### Type-check separately?

Add a tsc --noEmit step (in parallel) for type safety since SWC only strips types. Both run on CI runners; faster managed runners shorten long type-check passes on large codebases.

### Which should I choose?

Want the fastest TypeScript execution: ts-node with the SWC register (or @swc-node), plus a separate tsc --noEmit check. Need type-aware execution in one tool: plain ts-node. Most pipelines split speed from type-checking.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
