You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 51ce159
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: deps/amaro/README.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,26 @@
1
1
# Amaro
2
2
3
-
Amaro is a wrapper around `@swc/wasm-typescript`, a WebAssembly port of the SWC TypeScript parser.
3
+
Amaro is a Node.js wrapper around the [SWC](https://swc.rs) TypeScript parser and type stripper. Its Rust core in `crates/amaro` depends on the published SWC crates and is compiled to WebAssembly.
4
4
It's used as an internal in Node.js for [Type Stripping](https://nodejs.org/api/typescript.html#type-stripping) but can also be used as a standalone package.
5
5
6
6
> Amaro means "bitter" in Italian. It's a reference to [Mount Amaro](https://en.wikipedia.org/wiki/Monte_Amaro_(Abruzzo)) on whose slopes this package was conceived.
7
7
8
8
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.
9
9
10
+
## Building from source
11
+
12
+
The WebAssembly module is not checked in. Building it requires Docker, which
13
+
runs the Rust build inside the [Node.js wasm-builder](https://github.com/nodejs/wasm-builder)
14
+
container:
15
+
16
+
```bash
17
+
npm run build:wasm
18
+
npm run build
19
+
npm test
20
+
```
21
+
22
+
Releases build the module in CI before publishing.
> Note that the `amaro/transform` loader should be used with `--enable-source-maps`
48
62
> to preserve accurate source-mapped stack traces.
49
63
50
-
#### Programmatic registration with `module.register()`
64
+
#### Programmatic registration with `module.registerHooks()`
51
65
52
-
If you want TypeScript to "just work" in an existing codebase without passing `--import` every time, create a small bootstrap file and register Amaro once before loading your TS entrypoint.
66
+
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.
0 commit comments