scriptc 0.2.4 → 0.2.6

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 CHANGED
@@ -34,7 +34,7 @@ Builds use a bounded persistent cache. Unchanged source can reuse the validated
34
34
  - `scriptc run <file.ts>` — compile and run
35
35
  - `scriptc coverage <file.ts>` — what compiles statically, and why the rest doesn't
36
36
 
37
- `scriptc build app.ts --emit=ir|llvm|asm|obj` selects serialized typed IR, textual LLVM IR, target assembly, or a relocatable program object as the one primary artifact. `--emit=exe` is the default. Assembly/object emission uses the matching helper on supported macOS, Linux, and Windows hosts (and produces WASI artifacts when that target is selected). Objects retain undefined `scr_*` runtime references plus the `scr_runtime_abi_v6` compatibility marker; they are not library archives. External consumption is experimental and requires the exact matching runtime. `scriptc build app.ts --print=native-link-info -o app.o` prints the versioned JSON target/runtime/link recipe without performing a link. `--emit=asm|obj --sanitize` is rejected until ASan pipeline parity is available.
37
+ `scriptc build app.ts --emit=ir|llvm|asm|obj` selects serialized typed IR, textual LLVM IR, target assembly, or a relocatable program object as the one primary artifact. `--emit=exe` is the default. Assembly/object emission uses the matching helper on supported macOS, Linux, and Windows hosts (and produces WASI artifacts when that target is selected). Objects retain undefined `scr_*` runtime references plus the `scr_runtime_abi_v7` compatibility marker; they are not library archives. External consumption is experimental and requires the exact matching runtime. `scriptc build app.ts --print=native-link-info -o app.o` prints the versioned JSON target/runtime/link recipe without performing a link. `--emit=asm|obj --sanitize` is rejected until ASan pipeline parity is available.
38
38
 
39
39
  For embedder-hosted modules that are not installed npm packages, coverage can map an exact bare specifier to a local declaration with repeatable `--external-types <specifier=file.d.ts>` options. This is analysis-only: the types unblock application measurement, while runtime module uses remain reported as blockers.
40
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scriptc",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Compile ordinary TypeScript and JavaScript to small, fast native executables — no Node, no V8, no JavaScript engine in the binary",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://scriptc.dev",
@@ -21,16 +21,16 @@
21
21
  "node": ">=24"
22
22
  },
23
23
  "devDependencies": {
24
- "@scriptc/compiler": "0.2.4"
24
+ "@scriptc/compiler": "0.2.6"
25
25
  },
26
26
  "optionalDependencies": {
27
- "@scriptc/cli-darwin-x64": "0.2.4",
28
- "@scriptc/cli-linux-arm64-gnu": "0.2.4",
29
- "@scriptc/cli-linux-x64-gnu": "0.2.4",
30
- "@scriptc/cli-linux-arm64-musl": "0.2.4",
31
- "@scriptc/cli-darwin-arm64": "0.2.4",
32
- "@scriptc/cli-linux-x64-musl": "0.2.4",
33
- "@scriptc/cli-win32-x64-msvc": "0.2.4"
27
+ "@scriptc/cli-darwin-arm64": "0.2.6",
28
+ "@scriptc/cli-darwin-x64": "0.2.6",
29
+ "@scriptc/cli-linux-arm64-musl": "0.2.6",
30
+ "@scriptc/cli-linux-arm64-gnu": "0.2.6",
31
+ "@scriptc/cli-linux-x64-gnu": "0.2.6",
32
+ "@scriptc/cli-linux-x64-musl": "0.2.6",
33
+ "@scriptc/cli-win32-x64-msvc": "0.2.6"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json",
@@ -1,4 +1,15 @@
1
- import { constants, copyFileSync, chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
1
+ import {
2
+ constants,
3
+ copyFileSync,
4
+ chmodSync,
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ realpathSync,
9
+ renameSync,
10
+ rmSync,
11
+ writeFileSync,
12
+ } from "node:fs";
2
13
  import { createRequire } from "node:module";
3
14
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
4
15
  import { fileURLToPath } from "node:url";
@@ -8,7 +19,8 @@ export function nativeCliPackage(platform, architecture, libc) {
8
19
  if (host === "darwin-arm64" || host === "darwin-x64") return `@scriptc/cli-${host}`;
9
20
  if (host === "win32-x64") return "@scriptc/cli-win32-x64-msvc";
10
21
  if (host === "linux-x64" || host === "linux-arm64") {
11
- if (libc !== "glibc" && libc !== "musl") throw new Error("could not identify the Linux C library");
22
+ if (libc !== "glibc" && libc !== "musl")
23
+ throw new Error("could not identify the Linux C library");
12
24
  return `@scriptc/cli-${host}-${libc === "musl" ? "musl" : "gnu"}`;
13
25
  }
14
26
  throw new Error(`scriptc has no native command for ${host}`);
@@ -28,38 +40,65 @@ function hostLibc() {
28
40
  export function relocateToolchain(manifest, sourceDirectory, destinationDirectory) {
29
41
  const relocated = { ...manifest };
30
42
  const pathFrom = (value) => relative(destinationDirectory, resolve(sourceDirectory, value));
31
- for (const name of ["ts7", "llvm_package", "runtime_pack", "runtime_sources", "declarations", "comptime", "wasi_node_runner"]) {
43
+ for (const name of [
44
+ "ts7",
45
+ "llvm_package",
46
+ "runtime_pack",
47
+ "runtime_sources",
48
+ "declarations",
49
+ "comptime",
50
+ "wasi_node_runner",
51
+ ]) {
32
52
  if (typeof relocated[name] === "string") relocated[name] = pathFrom(relocated[name]);
33
53
  }
34
54
  for (const name of ["linker", "dsymutil", "archiver", "relocatable_linker"]) {
35
55
  const value = relocated[name];
36
- if (typeof value === "string" && !isAbsolute(value) && /[/\\]/.test(value)) relocated[name] = pathFrom(value);
56
+ if (typeof value === "string" && !isAbsolute(value) && /[/\\]/.test(value))
57
+ relocated[name] = pathFrom(value);
37
58
  }
38
- if (relocated.runtime_packs) relocated.runtime_packs = relocated.runtime_packs.map((pack) => ({ ...pack, path: pathFrom(pack.path) }));
59
+ if (relocated.runtime_packs)
60
+ relocated.runtime_packs = relocated.runtime_packs.map((pack) => ({
61
+ ...pack,
62
+ path: pathFrom(pack.path),
63
+ }));
39
64
  return relocated;
40
65
  }
41
66
 
42
- export function installNativeCli(directory, packageName = nativeCliPackage(process.platform, process.arch, hostLibc())) {
67
+ export function installNativeCli(
68
+ directory,
69
+ packageName = nativeCliPackage(process.platform, process.arch, hostLibc()),
70
+ ) {
43
71
  directory = realpathSync(directory);
44
72
  const require = createRequire(join(directory, "package.json"));
45
73
  const packageManifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
46
74
  const version = packageManifest.version;
47
75
  let platformManifest;
48
- try { platformManifest = require.resolve(`${packageName}/package.json`); }
49
- catch { throw new Error(`scriptc requires ${packageName}@${version}; reinstall with optional dependencies enabled`); }
76
+ try {
77
+ platformManifest = require.resolve(`${packageName}/package.json`);
78
+ } catch {
79
+ throw new Error(
80
+ `scriptc requires ${packageName}@${version}; reinstall with optional dependencies enabled`,
81
+ );
82
+ }
50
83
  const identity = JSON.parse(readFileSync(platformManifest, "utf8"));
51
- if (identity.name !== packageName || identity.version !== version) throw new Error(`scriptc requires ${packageName}@${version}, found ${identity.version}`);
84
+ if (identity.name !== packageName || identity.version !== version)
85
+ throw new Error(`scriptc requires ${packageName}@${version}, found ${identity.version}`);
52
86
  const sourceDirectory = join(dirname(platformManifest), "dist", "bin");
53
87
  const source = join(sourceDirectory, process.platform === "win32" ? "scriptc.exe" : "scriptc");
54
88
  const original = JSON.parse(readFileSync(source + ".json", "utf8"));
55
- if (original.schema !== "scriptc.native-toolchain.v1" || original.compiler_version !== version) throw new Error("native compiler toolchain version does not match this installation");
89
+ if (original.schema !== "scriptc.native-toolchain.v1" || original.compiler_version !== version)
90
+ throw new Error("native compiler toolchain version does not match this installation");
56
91
  const bin = join(directory, "bin");
57
92
  mkdirSync(bin, { recursive: true });
58
93
  const manifest = relocateToolchain(original, sourceDirectory, bin);
59
94
  // npm normalizes modes for payloads outside package bin entries. These
60
95
  // tools are launched directly by the compiler after installation.
61
96
  if (process.platform !== "win32") {
62
- for (const path of [manifest.ts7, manifest.comptime, join(manifest.llvm_package, "bin/scriptc-llvm-codegen")]) {
97
+ for (const path of [
98
+ manifest.ts7,
99
+ manifest.comptime,
100
+ join(manifest.llvm_package, "bin/scriptc-llvm-codegen"),
101
+ ]) {
63
102
  chmodSync(resolve(bin, path), 0o755);
64
103
  }
65
104
  }
@@ -86,10 +125,11 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
86
125
  const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
87
126
  // A source checkout builds the native distribution separately. pnpm pack
88
127
  // replaces workspace ranges with release versions before publication.
89
- const workspace = Object.values(manifest.optionalDependencies ?? {}).some((value) => String(value).startsWith("workspace:"));
128
+ const workspace = Object.values(manifest.optionalDependencies ?? {}).some((value) =>
129
+ String(value).startsWith("workspace:"),
130
+ );
90
131
  if (!workspace) installNativeCli(directory);
91
- }
92
- catch (error) {
132
+ } catch (error) {
93
133
  process.stderr.write(`scriptc: ${error instanceof Error ? error.message : String(error)}\n`);
94
134
  process.exitCode = 1;
95
135
  }
@@ -8,8 +8,11 @@ export function prepareNativeCommand(directory) {
8
8
  // npm creates bin links before postinstall. The payload must exist in the
9
9
  // tarball, and no shebang may pin the Windows shim to an interpreter.
10
10
  // Installation replaces this placeholder with the platform executable.
11
- writeFileSync(join(bin, "scriptc.exe"),
12
- "echo 'scriptc: native installation is incomplete; enable install scripts and reinstall scriptc' >&2\nexit 1\n", { mode: 0o755 });
11
+ writeFileSync(
12
+ join(bin, "scriptc.exe"),
13
+ "echo 'scriptc: native installation is incomplete; enable install scripts and reinstall scriptc' >&2\nexit 1\n",
14
+ { mode: 0o755 },
15
+ );
13
16
  rmSync(join(bin, "scriptc.exe.json"), { force: true });
14
17
  }
15
18