mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
Scope-B milestone NI-1, API side: the explicit call API that replaces the build container's hand-written node subprocess (api patch 09). - The new package @scriptc/node exports callSync(specifier, name, ...args) and call(...). The module loads with require() from the calling module; arguments and results cross as JSON copies; a thrown Error crosses as its nearest intrinsic class with its message and string code, other thrown values as JSON copies; callSync refuses a function that returns a promise. Its Node implementation runs the calls in-process with the same copies, so a program prints the same under Node and compiled. - The compiler lowers calls to the named or namespace imports (node-api-import.ts, lower-node-island.ts) to the nodeIsland.callSync and nodeIsland.call libCalls: the calling module's real path, the specifier, the export name and the boxed argument array, with the result checked against the declared type like `JSON.parse(s) as T`. Arguments and results whose types are not JSON data are refused at build time, and the functions and the namespace refuse as values. - Corpus programs 6800-6803 (sync and async results, errors, process.exit from Node with the program's exit listeners, Node's pending timers keeping the program alive) run under Node and as binaries that load libnode; `// @requires-libnode` skips them where SCRIPTC_LIBNODE names no pack (until the pack CI matrix publishes packs). The node-island harness covers loading Node only on the first call, the beside packaging, a missing pack, a pack of another Node version or bridge ABI, and the executable's symbols. - Release tooling publishes @scriptc/node with the other packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
// Stamps the version from packages/cli/package.json into packages/runtime
|
|
// packages/compiler, runtime, and platform helper packages so every component
|
|
// participating in the helper protocol moves in lockstep.
|
|
// Usage: node scripts/sync-versions.mjs
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = fileURLToPath(new URL("..", import.meta.url));
|
|
const manifest = (pkg) => `${root}packages/${pkg}/package.json`;
|
|
const read = (path) => JSON.parse(readFileSync(path, "utf8"));
|
|
|
|
const version = read(manifest("cli")).version;
|
|
if (typeof version !== "string" || version.length === 0) {
|
|
console.error("packages/cli/package.json has no version");
|
|
process.exit(1);
|
|
}
|
|
|
|
for (const pkg of [
|
|
"runtime",
|
|
"runtime-darwin-arm64",
|
|
"runtime-darwin-x64",
|
|
"runtime-linux-x64-gnu",
|
|
"runtime-linux-arm64-gnu",
|
|
"runtime-linux-x64-musl",
|
|
"runtime-linux-arm64-musl",
|
|
"runtime-win32-x64-msvc",
|
|
"runtime-wasm32-wasi",
|
|
"runtime-ios-arm64",
|
|
"runtime-ios-simulator-arm64",
|
|
"runtime-android-arm64",
|
|
"compiler",
|
|
"experimental",
|
|
"node",
|
|
"threads",
|
|
"types",
|
|
"cli-darwin-arm64",
|
|
"cli-darwin-x64",
|
|
"cli-linux-x64-gnu",
|
|
"cli-linux-arm64-gnu",
|
|
"cli-linux-x64-musl",
|
|
"cli-linux-arm64-musl",
|
|
"cli-win32-x64-msvc",
|
|
"llvm-darwin-arm64",
|
|
"llvm-darwin-x64",
|
|
"llvm-linux-x64-gnu",
|
|
"llvm-linux-arm64-gnu",
|
|
"llvm-linux-x64-musl",
|
|
"llvm-linux-arm64-musl",
|
|
"llvm-win32-x64-msvc",
|
|
]) {
|
|
const path = manifest(pkg);
|
|
const json = read(path);
|
|
if (json.version === version) {
|
|
console.log(`packages/${pkg}: already ${version}`);
|
|
continue;
|
|
}
|
|
console.log(`packages/${pkg}: ${json.version} -> ${version}`);
|
|
json.version = version;
|
|
writeFileSync(path, JSON.stringify(json, null, 2) + "\n");
|
|
}
|