amaro 0.1.9 → 0.2.1
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 +15 -0
- package/dist/index.js +49 -72
- package/dist/package.json +1 -1
- package/dist/register-strip.mjs +3 -0
- package/dist/register-transform.mjs +12 -0
- package/dist/strip-loader.js +24 -0
- package/dist/transform-loader.js +30 -0
- package/package.json +11 -5
- package/dist/register.mjs +0 -3
package/dist/package.json
CHANGED
|
@@ -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);
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amaro",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Node.js TypeScript wrapper",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -21,14 +21,15 @@
|
|
|
21
21
|
"ci:fix": "biome check --write",
|
|
22
22
|
"prepack": "npm run build",
|
|
23
23
|
"postpack": "npm run clean",
|
|
24
|
-
"build": "node esbuild.config.
|
|
24
|
+
"build": "node esbuild.config.mjs",
|
|
25
|
+
"build:wasm": "node tools/build-wasm.js",
|
|
25
26
|
"typecheck": "tsc --noEmit",
|
|
26
27
|
"test": "node --test --experimental-test-snapshots \"**/*.test.js\"",
|
|
27
28
|
"test:regenerate": "node --test --experimental-test-snapshots --test-update-snapshots \"**/*.test.js\""
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@biomejs/biome": "1.8.3",
|
|
31
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
32
33
|
"esbuild": "^0.23.0",
|
|
33
34
|
"esbuild-plugin-copy": "^2.1.1",
|
|
34
35
|
"rimraf": "^6.0.1",
|
|
@@ -36,7 +37,12 @@
|
|
|
36
37
|
},
|
|
37
38
|
"exports": {
|
|
38
39
|
".": "./dist/index.js",
|
|
39
|
-
"./register": "./dist/register.mjs"
|
|
40
|
+
"./register": "./dist/register-strip.mjs",
|
|
41
|
+
"./strip": "./dist/register-strip.mjs",
|
|
42
|
+
"./transform": "./dist/register-transform.mjs"
|
|
40
43
|
},
|
|
41
|
-
"files": ["dist", "LICENSE.md"]
|
|
44
|
+
"files": ["dist", "LICENSE.md"],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22"
|
|
47
|
+
}
|
|
42
48
|
}
|
package/dist/register.mjs
DELETED