Skip to content

Repository files navigation

rscute

npm version CI license

A lightweight, SWC-powered TypeScript JIT runner for Node.js.

The name comes from RS (Rust, via SWC) + cute (execute) — nimble, lightweight, smart execution. rscute intercepts module imports on-the-fly and compiles TypeScript files on-demand — zero config, zero build step.

rscute adds TypeScript to Node.js without changing anything else about it — it defines no CLI flags of its own, so --watch, --inspect, --test, and NODE_OPTIONS behave exactly as Node documents them. It is also fully stateless: transformed code goes straight from SWC into the module loader, nothing is ever written to disk — no cache directory, nothing to clean up.

npx rscute script.ts

Why rscute?

Node.js 22+ can strip types natively, and tsx is the de facto standard runner — so why rscute?

rscute tsx ts-node node (native)
Transform engine SWC (Rust) esbuild (Go) TypeScript compiler strip-types
tsconfig.json paths resolution plugin required
Extensionless imports in ESM ❌ (.ts required)
Full TS syntax (enums, namespaces) limited¹
CJS + ESM in one process fragile ESM support
Watch mode
Works with node -r / --import
Install size (clean install) 25 MB 11 MB 28 MB² 0 MB
Dependencies 2 3 12 + typescript 0

¹ Native type stripping rejects enums/namespaces unless --experimental-transform-types is enabled. ² Including the required typescript peer dependency.

Pick rscute when you want SWC's transform pipeline (same engine as Next.js/Jest's @swc/jest), automatic tsconfig.json paths resolution, and seamless mixed CJS/ESM execution — in a codebase of ~300 lines you can audit in one sitting.

Pick native node if you want zero extra dependencies and your code uses explicit .ts extensions with no path aliases, enums, or .tsx.


Benchmarks

Wall-clock time to run a script to completion. Each number is the mean of 12 consecutive runs with no warmup runs discarded — the cold first run is included, and rscute keeps no on-disk cache, so every single run transpiles from scratch (Apple Silicon macOS, Node v25.8.2):

Scenario rscute tsx ts-node³ node (native)
Single file (CJS) 82 ms 159 ms 172 ms
Single file (ESM) 76 ms 159 ms 93 ms
30-module import chain (CJS) 85 ms 169 ms 226 ms
30-module import chain (ESM) 85 ms 167 ms 104 ms

³ ts-node --transpileOnly (type-checking disabled). Note: ts-node 10.x is incompatible with TypeScript 6.

Two structural choices make rscute the fastest runner in these benchmarks — faster even than native node:

  • The CLI registers its hooks in-process and runs your entry file directly — no child-process respawn. (When node flags such as --inspect are passed, rscute transparently falls back to spawning node so the flags take effect.)
  • Module hooks run synchronously on the loading thread via module.registerHooks (Node 22.15+) — no loader worker thread to spin up, no cross-thread messaging per module.

The lead holds as modules get heavier — every run below is a full on-demand transpile of all 30 files, no cache involved:

Scenario rscute tsx node (native)
30 files × ~300 lines (ESM) 145 ms 183 ms 154 ms

Quick Start

Installation

npm i -D rscute

Note: If you are using pnpm, run commands using pnpm exec instead of npx.

CLI Execution

npx rscute script.ts

Runs .ts, .tsx, .cts, and .mts files directly. Imports are resolved on demand — including extensionless specifiers, directory index files, and tsconfig.json path aliases.

As a preload hook

node --import rscute script.ts # ESM-style preload
node -r rscute script.ts       # CJS-style preload

Both register the hooks before your entry file runs, so they also work through NODE_OPTIONS — useful for tooling that spawns node for you:

NODE_OPTIONS="--import rscute" node --test src/**/*.test.ts

Watch mode

npx rscute --watch script.ts

Reruns the script whenever it or any file it imports changes. rscute passes node flags straight through to Node.js, so watch mode is simply Node's built-in watcher — no extra dependencies, and every --watch-* option works as documented by Node. The same pass-through applies to any other node flag: rscute --inspect script.ts enables the debugger, and so on.


Coming from tsx

rscute is a drop-in replacement for the common tsx commands:

tsx rscute
tsx script.ts rscute script.ts
tsx watch script.ts rscute --watch script.ts
node --import tsx script.ts node --import rscute script.ts
node -r tsx script.ts node -r rscute script.ts

Unlike tsx, rscute has no subcommands or CLI options of its own — flags are passed straight to node, so watch behavior (ignore rules, polling, etc.) is configured with Node's --watch-* flags.

Tip: in package.json scripts you don't need npx — bins in node_modules/.bin are already on the PATH, and invoking the bin directly skips npx's own startup overhead entirely:

{
  "scripts": {
    "dev": "rscute --watch src/main.ts",
    "start": "rscute src/main.ts",
  },
}

Programmatic API

rscute/register

Hook TypeScript compilation into Node.js module resolution programmatically:

const { register } = require('rscute/register');

register();

// Now you can require .ts files directly
require('./my-module.ts');

tsconfig path aliases

If your tsconfig.json defines paths, rscute resolves them automatically — no plugin, no configuration:

// tsconfig.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@utils/*": ["src/utils/*"],
    },
  },
}
import { helper } from '@utils/helper'; // just works

The nearest tsconfig.json is discovered from each importing file, so monorepo packages with different configs resolve independently. Resolution results are cached in memory for the duration of the process, and files inside node_modules are never transformed or re-resolved, keeping startup overhead minimal.


Requirements

  • Node.js >= 22.15.0

License

rscute is MIT licensed.

About

SWC-powered TypeScript JIT runner and bundler for Node.js

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages