Skip to content

Commit 3d979dd

Browse files
deps: update amaro to 0.2.0
PR-URL: nodejs#55601 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 824c149 commit 3d979dd

10 files changed

+112
-49
lines changed

deps/amaro/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ This allows the installed Amaro to override the Amaro version used by Node.js.
3434
node --experimental-strip-types --import="amaro/register" script.ts
3535
```
3636

37+
Or with the alias:
38+
39+
```bash
40+
node --experimental-strip-types --import="amaro/strip" script.ts
41+
```
42+
43+
Enabling TypeScript feature transformation:
44+
45+
```bash
46+
node --experimental-transform-types --import="amaro/transform" script.ts
47+
```
48+
49+
> Note that the "amaro/transform" loader should be used with `--experimental-transform-types` flag, or
50+
> at least with `--enable-source-maps` flag, to preserve the original source maps.
51+
3752
### How to update SWC
3853

3954
To update the SWC version, run:

deps/amaro/dist/index.js

+16-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/amaro/dist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"강동윤 <[email protected]>"
55
],
66
"description": "wasm module for swc",
7-
"version": "1.7.35",
7+
"version": "1.7.40",
88
"license": "Apache-2.0",
99
"repository": {
1010
"type": "git",

deps/amaro/dist/register-strip.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { register } from "node:module";
2+
3+
register("./strip-loader.js", import.meta.url);
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { register } from "node:module";
2+
import { emitWarning, env, execArgv } from "node:process";
3+
4+
const hasSourceMaps =
5+
execArgv.includes("--enable-source-maps") ||
6+
env.NODE_OPTIONS?.includes("--enable-source-maps");
7+
8+
if (!hasSourceMaps) {
9+
emitWarning("Source maps are disabled, stack traces will not accurate");
10+
}
11+
12+
register("./transform-loader.js", import.meta.url);

deps/amaro/dist/register.mjs

-3
This file was deleted.

deps/amaro/dist/strip-loader.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
import { transformSync } from "./index.js";
3+
export async function load(url, context, nextLoad) {
4+
const { format } = context;
5+
if (format.endsWith("-typescript")) {
6+
const { source } = await nextLoad(url, {
7+
...context,
8+
format: "module"
9+
});
10+
const { code } = transformSync(source.toString(), {
11+
mode: "strip-only"
12+
});
13+
return {
14+
format: format.replace("-typescript", ""),
15+
// Source map is not necessary in strip-only mode. However, to map the source
16+
// file in debuggers to the original TypeScript source, add a sourceURL magic
17+
// comment to hint that it is a generated source.
18+
source: `${code}
19+
20+
//# sourceURL=${url}`
21+
};
22+
}
23+
return nextLoad(url, context);
24+
}

deps/amaro/dist/transform-loader.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"use strict";
2+
import { transformSync } from "./index.js";
3+
export async function load(url, context, nextLoad) {
4+
const { format } = context;
5+
if (format.endsWith("-typescript")) {
6+
const { source } = await nextLoad(url, {
7+
...context,
8+
format: "module"
9+
});
10+
const { code, map } = transformSync(source.toString(), {
11+
mode: "transform",
12+
sourceMap: true,
13+
filename: url
14+
});
15+
let output = code;
16+
if (map) {
17+
const base64SourceMap = Buffer.from(map).toString("base64");
18+
output = `${code}
19+
20+
//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`;
21+
}
22+
return {
23+
format: format.replace("-typescript", ""),
24+
source: `${output}
25+
26+
//# sourceURL=${url}`
27+
};
28+
}
29+
return nextLoad(url, context);
30+
}

deps/amaro/package.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "amaro",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "Node.js TypeScript wrapper",
55
"license": "MIT",
66
"type": "commonjs",
@@ -21,22 +21,27 @@
2121
"ci:fix": "biome check --write",
2222
"prepack": "npm run build",
2323
"postpack": "npm run clean",
24-
"build": "node esbuild.config.js",
24+
"build": "node esbuild.config.mjs",
2525
"typecheck": "tsc --noEmit",
2626
"test": "node --test --experimental-test-snapshots \"**/*.test.js\"",
2727
"test:regenerate": "node --test --experimental-test-snapshots --test-update-snapshots \"**/*.test.js\""
2828
},
2929
"devDependencies": {
3030
"@biomejs/biome": "1.8.3",
31-
"@types/node": "^20.14.11",
31+
"@types/node": "^22.0.0",
3232
"esbuild": "^0.23.0",
3333
"esbuild-plugin-copy": "^2.1.1",
3434
"rimraf": "^6.0.1",
3535
"typescript": "^5.5.3"
3636
},
3737
"exports": {
3838
".": "./dist/index.js",
39-
"./register": "./dist/register.mjs"
39+
"./register": "./dist/register-strip.mjs",
40+
"./strip": "./dist/register-strip.mjs",
41+
"./transform": "./dist/register-transform.mjs"
4042
},
41-
"files": ["dist", "LICENSE.md"]
43+
"files": ["dist", "LICENSE.md"],
44+
"engines": {
45+
"node": ">=22"
46+
}
4247
}

src/amaro_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/dep_updaters/update-amaro.sh
33
#ifndef SRC_AMARO_VERSION_H_
44
#define SRC_AMARO_VERSION_H_
5-
#define AMARO_VERSION "0.1.9"
5+
#define AMARO_VERSION "0.2.0"
66
#endif // SRC_AMARO_VERSION_H_

0 commit comments

Comments
 (0)