hermesx
Run TypeScript files using the Hermes JavaScript engine with automatic transpilation. Basically tsx but with Hermes as engine.
It's useful especially if you want to do performance profiling of your code quickly on your computer without need to building whole React Native project. Problem with using Node/Bun is that it's engine V8/JSC (+JIT) is much faster so it doesn't give you accurate results for how code will perform in React Native app.
Features
- ✅ TypeScript Support: Runs TypeScript code seamlessly
- ✅ Metro Bundler: Uses Rspack + Babel with React Native preset, so it's similar to how React Native bundles code
- ✅ Hermes Engine: Uses same engine as React Native
- ✅ Automatic Setup: Downloads and caches latest Hermes binary on first run
- ✅ External Modules: Import and use npm packages like lodash, date-fns, etc. from current project
Installation
# Install globally
bun install -g hermesx
# or
npm install -g hermesx
# Or use with bunx
bunx hermesx script.ts
# or
npx hermesx script.ts
Usage
# Run a TypeScript file
bunx hermesx script.ts
# or
npx hermesx script.ts
# Show help
npx hermesx --help
# Show version
npx hermesx --version
Limitations
Hermes has very limited APIs, so some features are not available (for example fetch). Please check Limitations section for more details.
Examples
Basic TypeScript
// hello.ts
const message: string = "Hello from hermesx!";
const user = { name: "Alice", age: 30, active: true };
const items = [1, 2, { type: "example" }];
console.log(message);
console.log("User object:", user);
console.log("Items array:", items);
hermesx hello.ts
# Output: Hello from hermesx!
# User object: {
# "name": "Alice",
# "age": 30,
# "active": true
# }
# Items array: [
# 1,
# 2,
# {
# "type": "example"
# }
# ]