| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | "강동윤 <kdy1997.dev@gmail.com>" | |
| 5 | 5 | ], | |
| 6 | 6 | "description": "wasm module for swc", | |
| 7 | - "version": "1.11.24", | ||
| 7 | + "version": "1.11.31", | ||
| 8 | 8 | "license": "Apache-2.0", | |
| 9 | 9 | "repository": { | |
| 10 | 10 | "type": "git", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "name": "amaro", | |
| 3 | - "version": "0.5.3", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | 4 | "description": "Node.js TypeScript wrapper", | |
| 5 | 5 | "license": "MIT", | |
| 6 | 6 | "type": "commonjs", | |
@@ -37,7 +37,6 @@ | |||
| 37 | 37 | }, | |
| 38 | 38 | "exports": { | |
| 39 | 39 | ".": "./dist/index.js", | |
| 40 | - "./register": "./dist/register-strip.mjs", | ||
| 41 | 40 | "./strip": "./dist/register-strip.mjs", | |
| 42 | 41 | "./transform": "./dist/register-transform.mjs" | |
| 43 | 42 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,5 +2,5 @@ | |||
| 2 | 2 | // Refer to tools/dep_updaters/update-amaro.sh | |
| 3 | 3 | #ifndef SRC_AMARO_VERSION_H_ | |
| 4 | 4 | #define SRC_AMARO_VERSION_H_ | |
| 5 | - #define AMARO_VERSION "0.5.3" | ||
| 5 | + #define AMARO_VERSION "1.0.0" | ||
| 6 | 6 | #endif // SRC_AMARO_VERSION_H_ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments