Skip to content

⚡️ Rust Execute: TypeScript ESM & CJS faster execution in memory with swc

License

Notifications You must be signed in to change notification settings

refirst11/rscute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rscute · powered by SWC

Faster Executor for TypeScript using @swc/core

Installation

npm:

npm i -D rscute

pnpm:

pnpm add -D rscute

When using pnpm, use pnpm exec instead of npx for running commands.

Usage

CLI

Run your TypeScript files directly from the command line.

Run a single file:

npx rscute script.ts

Run multiple files (sequential by default):

npx rscute script-a.ts script-b.ts

Run multiple files in parallel(-p or --parallel):

npx rscute script-a.ts script-b.ts -p

Require Hook

Enable on-the-fly TypeScript compilation for require().

From the command line:

node -r rscute script.ts

From within your code:

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

register();

require('./filename.ts');

Programmatic API

Use rscute's APIs for advanced control within your own scripts.

execute(absolutePath)

The core API to execute a single file. Requires an absolute path for robust execution.

import { execute } from 'rscute/execute';
import path from 'path';

const absolutePath = path.resolve(__dirname, './script.ts');
execute(absolutePath);

run(files, options)

The API for the CLI. Handles relative paths, multiple files, and execution modes.

import { run } from 'rscute/cli';

// Run two files in parallel(default: sequential)
await run(['./script-a.ts', './script-b.ts'], { mode: 'parallel' });

Concept

rscute executes the code that did the path resolution in the Function constructor, which is done in memory. Supported extensions are .js, .ts, .mjs, .mts, .cjs, .cts, .jsx, and .tsx.


License

rscute is MIT licensed.

About

⚡️ Rust Execute: TypeScript ESM & CJS faster execution in memory with swc

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published