amaro 0.5.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Amaro
2
2
 
3
3
  Amaro is a wrapper around `@swc/wasm-typescript`, a WebAssembly port of the SWC TypeScript parser.
4
- It's currently used as an internal in Node.js for [Type Stripping](https://github.com/nodejs/loaders/issues/208), but in the future it will be possible to be upgraded separately by users.
5
- The main goal of this package is to provide a stable API for TypeScript parser, which is unstable and subject to change.
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.
6
5
 
7
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.
8
7
 
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
  ## How to Install
10
11
 
11
12
  To install Amaro, run:
@@ -31,25 +32,48 @@ It is possible to use Amaro as an external loader to execute TypeScript files.
31
32
  This allows the installed Amaro to override the Amaro version used by Node.js.
32
33
  In order to use Amaro as an external loader, type stripping needs to be enabled.
33
34
 
34
- ```bash
35
- node --experimental-strip-types --import="amaro/register" script.ts
36
- ```
37
-
38
- Or with the alias:
35
+ In node v23 and later you can omit the `--experimental-strip-types` flag, as it is enabled by default.
39
36
 
40
37
  ```bash
41
- node --experimental-strip-types --import="amaro/strip" script.ts
38
+ node --experimental-strip-types --import="amaro/strip" file.ts
42
39
  ```
43
40
 
44
41
  Enabling TypeScript feature transformation:
45
42
 
46
43
  ```bash
47
- node --experimental-transform-types --import="amaro/transform" script.ts
44
+ node --experimental-transform-types --import="amaro/transform" file.ts
48
45
  ```
49
46
 
50
47
  > Note that the "amaro/transform" loader should be used with `--experimental-transform-types` flag, or
51
48
  > at least with `--enable-source-maps` flag, to preserve the original source maps.
52
49
 
50
+ #### Type stripping in dependencies
51
+
52
+ Contrary to the Node.js [TypeScript support](https://nodejs.org/docs/latest/api/typescript.html#type-stripping-in-dependencies), when used as a loader, Amaro handles TypeScript files inside folders under a `node_modules` path.
53
+
54
+ ### Monorepo usage
55
+
56
+ Amaro makes working in monorepos smoother by removing the need to rebuild internal packages during development. When used with the [`--conditions`](https://nodejs.org/docs/latest/api/cli.html#-c-condition---conditionscondition) flag, you can reference TypeScript source files directly in exports:
57
+
58
+ ```json
59
+ "exports": {
60
+ ".": {
61
+ "typescript": "./src/index.ts",
62
+ "types": "./dist/index.d.ts",
63
+ "require": "./dist/index.js",
64
+ "import": "./dist/index.js"
65
+ }
66
+ }
67
+ ```
68
+
69
+ Then run your app with:
70
+
71
+ ```bash
72
+ node --watch --import="amaro/strip" --conditions=typescript ./src/index.ts
73
+ ```
74
+
75
+ 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.
76
+
53
77
  ### TypeScript Version
54
78
 
55
79
  The supported TypeScript version is 5.8.