amaro 0.1.9 → 0.2.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/dist/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "강동윤 <kdy1997.dev@gmail.com>"
5
5
  ],
6
6
  "description": "wasm module for swc",
7
- "version": "1.7.35",
7
+ "version": "1.7.40",
8
8
  "license": "Apache-2.0",
9
9
  "repository": {
10
10
  "type": "git",
@@ -0,0 +1,3 @@
1
+ import { register } from "node:module";
2
+
3
+ register("./strip-loader.js", import.meta.url);
@@ -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.9",
3
+ "version": "0.2.0",
4
4
  "description": "Node.js TypeScript wrapper",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -21,14 +21,14 @@
21
21
  "ci:fix": "biome check --write",
22
22
  "prepack": "npm run build",
23
23
  "postpack": "npm run clean",
24
- "build": "node esbuild.config.js",
24
+ "build": "node esbuild.config.mjs",
25
25
  "typecheck": "tsc --noEmit",
26
26
  "test": "node --test --experimental-test-snapshots \"**/*.test.js\"",
27
27
  "test:regenerate": "node --test --experimental-test-snapshots --test-update-snapshots \"**/*.test.js\""
28
28
  },
29
29
  "devDependencies": {
30
30
  "@biomejs/biome": "1.8.3",
31
- "@types/node": "^20.14.11",
31
+ "@types/node": "^22.0.0",
32
32
  "esbuild": "^0.23.0",
33
33
  "esbuild-plugin-copy": "^2.1.1",
34
34
  "rimraf": "^6.0.1",
@@ -36,7 +36,12 @@
36
36
  },
37
37
  "exports": {
38
38
  ".": "./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"
40
42
  },
41
- "files": ["dist", "LICENSE.md"]
43
+ "files": ["dist", "LICENSE.md"],
44
+ "engines": {
45
+ "node": ">=22"
46
+ }
42
47
  }
package/dist/register.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { register } from "node:module";
2
-
3
- register("./index.js", import.meta.url);