mirror of https://github.com/nodejs/node.git
deps: update amaro to 0.2.0
PR-URL: https://github.com/nodejs/node/pull/55601 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>pull/55741/head
parent
5de2567644
commit
3477492588
|
@ -34,6 +34,21 @@ This allows the installed Amaro to override the Amaro version used by Node.js.
|
|||
node --experimental-strip-types --import="amaro/register" script.ts
|
||||
```
|
||||
|
||||
Or with the alias:
|
||||
|
||||
```bash
|
||||
node --experimental-strip-types --import="amaro/strip" script.ts
|
||||
```
|
||||
|
||||
Enabling TypeScript feature transformation:
|
||||
|
||||
```bash
|
||||
node --experimental-transform-types --import="amaro/transform" script.ts
|
||||
```
|
||||
|
||||
> Note that the "amaro/transform" loader should be used with `--experimental-transform-types` flag, or
|
||||
> at least with `--enable-source-maps` flag, to preserve the original source maps.
|
||||
|
||||
### How to update SWC
|
||||
|
||||
To update the SWC version, run:
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
"강동윤 <kdy1997.dev@gmail.com>"
|
||||
],
|
||||
"description": "wasm module for swc",
|
||||
"version": "1.7.35",
|
||||
"version": "1.7.40",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
import { register } from "node:module";
|
||||
|
||||
register("./strip-loader.js", import.meta.url);
|
|
@ -0,0 +1,12 @@
|
|||
import { register } from "node:module";
|
||||
import { emitWarning, env, execArgv } from "node:process";
|
||||
|
||||
const hasSourceMaps =
|
||||
execArgv.includes("--enable-source-maps") ||
|
||||
env.NODE_OPTIONS?.includes("--enable-source-maps");
|
||||
|
||||
if (!hasSourceMaps) {
|
||||
emitWarning("Source maps are disabled, stack traces will not accurate");
|
||||
}
|
||||
|
||||
register("./transform-loader.js", import.meta.url);
|
|
@ -1,3 +0,0 @@
|
|||
import { register } from "node:module";
|
||||
|
||||
register("./index.js", import.meta.url);
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
import { transformSync } from "./index.js";
|
||||
export async function load(url, context, nextLoad) {
|
||||
const { format } = context;
|
||||
if (format.endsWith("-typescript")) {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code } = transformSync(source.toString(), {
|
||||
mode: "strip-only"
|
||||
});
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
// Source map is not necessary in strip-only mode. However, to map the source
|
||||
// file in debuggers to the original TypeScript source, add a sourceURL magic
|
||||
// comment to hint that it is a generated source.
|
||||
source: `${code}
|
||||
|
||||
//# sourceURL=${url}`
|
||||
};
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
import { transformSync } from "./index.js";
|
||||
export async function load(url, context, nextLoad) {
|
||||
const { format } = context;
|
||||
if (format.endsWith("-typescript")) {
|
||||
const { source } = await nextLoad(url, {
|
||||
...context,
|
||||
format: "module"
|
||||
});
|
||||
const { code, map } = transformSync(source.toString(), {
|
||||
mode: "transform",
|
||||
sourceMap: true,
|
||||
filename: url
|
||||
});
|
||||
let output = code;
|
||||
if (map) {
|
||||
const base64SourceMap = Buffer.from(map).toString("base64");
|
||||
output = `${code}
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`;
|
||||
}
|
||||
return {
|
||||
format: format.replace("-typescript", ""),
|
||||
source: `${output}
|
||||
|
||||
//# sourceURL=${url}`
|
||||
};
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "amaro",
|
||||
"version": "0.1.9",
|
||||
"version": "0.2.0",
|
||||
"description": "Node.js TypeScript wrapper",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
|
@ -21,14 +21,14 @@
|
|||
"ci:fix": "biome check --write",
|
||||
"prepack": "npm run build",
|
||||
"postpack": "npm run clean",
|
||||
"build": "node esbuild.config.js",
|
||||
"build": "node esbuild.config.mjs",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "node --test --experimental-test-snapshots \"**/*.test.js\"",
|
||||
"test:regenerate": "node --test --experimental-test-snapshots --test-update-snapshots \"**/*.test.js\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.8.3",
|
||||
"@types/node": "^20.14.11",
|
||||
"@types/node": "^22.0.0",
|
||||
"esbuild": "^0.23.0",
|
||||
"esbuild-plugin-copy": "^2.1.1",
|
||||
"rimraf": "^6.0.1",
|
||||
|
@ -36,7 +36,12 @@
|
|||
},
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./register": "./dist/register.mjs"
|
||||
"./register": "./dist/register-strip.mjs",
|
||||
"./strip": "./dist/register-strip.mjs",
|
||||
"./transform": "./dist/register-transform.mjs"
|
||||
},
|
||||
"files": ["dist", "LICENSE.md"]
|
||||
"files": ["dist", "LICENSE.md"],
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// Refer to tools/dep_updaters/update-amaro.sh
|
||||
#ifndef SRC_AMARO_VERSION_H_
|
||||
#define SRC_AMARO_VERSION_H_
|
||||
#define AMARO_VERSION "0.1.9"
|
||||
#define AMARO_VERSION "0.2.0"
|
||||
#endif // SRC_AMARO_VERSION_H_
|
||||
|
|
Loading…
Reference in New Issue