@tsrs/wasm 0.0.0-bootstrap.1 → 0.16.0-ts7.1.0-dev.20260929
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/NOTICE.txt +416 -0
- package/README.md +105 -1
- package/bin/tsrs-wasm.js +13 -0
- package/browser.js +45 -0
- package/core.d.ts +105 -0
- package/core.js +356 -0
- package/index.d.ts +42 -0
- package/node-fs.js +117 -0
- package/node-run.js +55 -0
- package/node-worker.js +5 -0
- package/node.js +50 -0
- package/package.json +50 -7
- package/tsrs.wasm +0 -0
package/node.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Node entry point: `tsc(args, options)` runs tsrs.wasm in a fresh worker thread per call (the checker recurses
|
|
2
|
+
// deeply; a worker gets a large native stack through `resourceLimits.stackSizeMb`). The module is compiled once per
|
|
3
|
+
// process. Under Bun, which ignores the worker stack limit, the run stays on the calling thread.
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { Worker } from "node:worker_threads";
|
|
7
|
+
import { run } from "./node-run.js";
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_STACK_SIZE_MB = 256;
|
|
10
|
+
|
|
11
|
+
let compiled;
|
|
12
|
+
|
|
13
|
+
/** The compiled module (tsrs.wasm next to this file, or `TSRS_WASM` if set). */
|
|
14
|
+
export function loadModule() {
|
|
15
|
+
compiled ??= new WebAssembly.Module(fs.readFileSync(process.env.TSRS_WASM || new URL("./tsrs.wasm", import.meta.url)));
|
|
16
|
+
return compiled;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs tsc. options: { cwd, files, env, diagnostics: "text" | "json", tty, stdout, stderr ("inherit" to write to
|
|
21
|
+
* this process's fd 1 / 2; collected otherwise), caseInsensitive, stackSizeMb }.
|
|
22
|
+
* Resolves to { exitCode, stdout, stderr, diagnostics?, files?, memoryBytes }.
|
|
23
|
+
*/
|
|
24
|
+
export function tsc(args, options = {}) {
|
|
25
|
+
const module = loadModule();
|
|
26
|
+
const opts = { ...options, args: [...args] };
|
|
27
|
+
if (typeof Bun !== "undefined") {
|
|
28
|
+
return Promise.resolve().then(() => run(module, opts));
|
|
29
|
+
}
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const worker = new Worker(new URL("./node-worker.js", import.meta.url), {
|
|
32
|
+
workerData: { module, options: opts },
|
|
33
|
+
resourceLimits: { stackSizeMb: options.stackSizeMb ?? DEFAULT_STACK_SIZE_MB },
|
|
34
|
+
stdout: false,
|
|
35
|
+
stderr: false,
|
|
36
|
+
});
|
|
37
|
+
let settled = false;
|
|
38
|
+
worker.once("message", (result) => {
|
|
39
|
+
settled = true;
|
|
40
|
+
resolve(result);
|
|
41
|
+
});
|
|
42
|
+
worker.once("error", (e) => {
|
|
43
|
+
settled = true;
|
|
44
|
+
reject(e);
|
|
45
|
+
});
|
|
46
|
+
worker.once("exit", (code) => {
|
|
47
|
+
if (!settled) reject(new Error(`tsrs-wasm worker exited with code ${code}`));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrs/wasm",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"description": "Placeholder for @tsrs/wasm; the compiler will be available in a future release",
|
|
3
|
+
"version": "0.16.0-ts7.1.0-dev.20260929",
|
|
5
4
|
"license": "Apache-2.0",
|
|
5
|
+
"description": "tsrs (a Rust port of the TypeScript 7 compiler) as a WebAssembly module: tsc for Node and browsers, single-threaded",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"TypeScript",
|
|
8
|
+
"tsc",
|
|
9
|
+
"typecheck",
|
|
10
|
+
"wasm",
|
|
11
|
+
"webassembly",
|
|
12
|
+
"rust",
|
|
13
|
+
"compiler"
|
|
14
|
+
],
|
|
6
15
|
"repository": {
|
|
7
16
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
17
|
+
"url": "git+https://github.com/oxc-project/tsrs.git",
|
|
18
|
+
"directory": "npm/tsrs-wasm"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"tsrs-wasm": "bin/tsrs-wasm.js"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"node": "./node.js",
|
|
32
|
+
"default": "./browser.js"
|
|
33
|
+
},
|
|
34
|
+
"./core": {
|
|
35
|
+
"types": "./core.d.ts",
|
|
36
|
+
"default": "./core.js"
|
|
37
|
+
},
|
|
38
|
+
"./tsrs.wasm": "./tsrs.wasm"
|
|
9
39
|
},
|
|
10
40
|
"files": [
|
|
41
|
+
"bin",
|
|
42
|
+
"core.js",
|
|
43
|
+
"core.d.ts",
|
|
44
|
+
"node.js",
|
|
45
|
+
"node-run.js",
|
|
46
|
+
"node-worker.js",
|
|
47
|
+
"node-fs.js",
|
|
48
|
+
"browser.js",
|
|
49
|
+
"index.d.ts",
|
|
50
|
+
"tsrs.wasm",
|
|
11
51
|
"README.md",
|
|
12
|
-
"
|
|
52
|
+
"NOTICE.txt"
|
|
13
53
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
54
|
+
"tsrs": {
|
|
55
|
+
"typescriptVersion": "7.1.0-dev.20260929",
|
|
56
|
+
"typescriptCommit": "b85298b6a81f772d080b0455de0ca9d744cd6fd6"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"test": "node --test test/*.test.mjs"
|
|
17
60
|
}
|
|
18
61
|
}
|
package/tsrs.wasm
ADDED
|
Binary file
|