0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 20:29:23 +01:00
nodejs/deps/amaro
Node.js GitHub Bot c3fe2d60bd
deps: update amaro to 0.1.8
PR-URL: https://github.com/nodejs/node/pull/54520
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-08-25 10:12:37 +00:00
..
dist deps: update amaro to 0.1.8 2024-08-25 10:12:37 +00:00
LICENSE.md
package.json deps: update amaro to 0.1.8 2024-08-25 10:12:37 +00:00
README.md

Amaro

Amaro is a wrapper around @swc/wasm-typescript, a WebAssembly port of the SWC TypeScript parser. It's currently used as an internal in Node.js for Type Stripping, but in the future it will be possible to be upgraded separately by users. The main goal of this package is to provide a stable API for TypeScript parser, which is unstable and subject to change.

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

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.

node --experimental-strip-types --import="amaro/register" script.ts

How to update SWC

To update the SWC version, run:

./tools/update-swc.sh
git add deps
git commit -m "chore: update swc to vX.Y.Z"

Once you have updated the rust source code we must build the wasm. To build the wasm it is necessary to have Docker installed.

node ./tools/build-wasm.js
git add lib
git commit -m "chore: build wasm from swc vX.Y.Z"

TypeScript Version

The supported TypeScript version is 5.5.4.

License (MIT)

See LICENSE.md.