GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nodejs/amaro: Node.js TypeScript wrapper

BranchesTags
Open more actions menu

Latest commit

 

History

484 Commits
484 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
crates/amaro
crates/amaro
 
 
deps/swc
deps/swc
 
 
src
src
 
 
test
test
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
.nvmrc
.nvmrc
 
 
.release-please-manifest.json
.release-please-manifest.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
biome.json
biome.json
 
 
commitlint.config.mjs
commitlint.config.mjs
 
 
deny.toml
deny.toml
 
 
esbuild.config.mjs
esbuild.config.mjs
 
 
package.json
package.json
 
 
release-please-config.json
release-please-config.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Amaro

Amaro is a Node.js wrapper around the SWC TypeScript parser and type stripper. Its Rust core in crates/amaro depends on the published SWC crates and is compiled to WebAssembly. It's used as an internal in Node.js for Type Stripping but can also be used as a standalone package.

Amaro means "bitter" in Italian. It's a reference to Mount Amaro on whose slopes this package was conceived.

This package provides a stable API for the TypeScript parser and allows users to upgrade to the latest version of TypeScript transpiler independently from the one used internally in Node.js.

Building from source

The WebAssembly module is not checked in. Building it requires Docker, which runs the Rust build inside the Node.js wasm-builder container:

npm run build:wasm
npm run build
npm test

Releases build the module in CI before publishing.

How to Install

To install Amaro, run:

npm install amaro

How to Use

By default Amaro exports a transformSync function that performs type stripping. Stack traces are preserved, by replacing removed types with white spaces.

const amaro = require('amaro');
const { code } = amaro.transformSync("const foo: string = 'bar';", { mode: "strip-only" });
console.log(code); // "const foo         = 'bar';"

Loader

It is possible to use Amaro as an external loader to execute TypeScript files. This allows the installed Amaro to override the Amaro version used by Node.js. In order to use Amaro as an external loader, type stripping needs to be enabled.

node --import="amaro/strip" file.ts

In node v22.18.0 and later you can omit the --experimental-strip-types flag, as it is enabled by default.

Enabling TypeScript feature transformation:

node --enable-source-maps --import="amaro/transform" file.ts

Note that the amaro/transform loader should be used with --enable-source-maps to preserve accurate source-mapped stack traces.

Programmatic registration with module.registerHooks()

Amaro's strip and transform entry points use module.registerHooks() to register synchronous hooks on Node.js versions that provide it, and fall back to module.register() on older versions. If you want TypeScript to "just work" in an existing codebase without passing --import every time, create a small bootstrap file that imports Amaro before loading your TS entrypoint.

// bootstrap.mjs
import "amaro/strip";
await import("./src/index.ts");

Then start your app through the bootstrap file:

node --watch ./bootstrap.mjs

For transform mode, swap amaro/strip with amaro/transform and run Node with --enable-source-maps.

Monorepo usage

Amaro makes working in monorepos smoother by removing the need to rebuild internal packages during development. When used with the --conditions flag, you can reference TypeScript source files directly in exports:

"exports": {
  ".": {
    "typescript": "./src/index.ts",
    "types": "./dist/index.d.ts",
    "require": "./dist/index.js",
    "import": "./dist/index.js"
 }
}

Then run your app with:

node --watch --import="amaro/strip" --conditions=typescript ./src/index.ts

This setup allows Node.js to load TypeScript files from linked packages without a build step. Changes to any package are picked up immediately, speeding up and simplifying local development in monorepos.

TypeScript Version

The supported TypeScript version is 5.8.

License (MIT)

See LICENSE.md.

About

Node.js TypeScript wrapper

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

800 stars

Watchers

10 watching

Forks

38 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.