mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
T10 and T12 of the zero-cost compatibility plan, plus the maintainer decisions: - Programs that name Temporal type-check against TS 7's temporal lib (added only for them) and lower to Node 24's answers: typeof is "undefined", globalThis.Temporal is undefined, other uses throw ReferenceError at the root read. - node:v8 is importable; getHeapStatistics answers allocator-derived figures in Node's shape; other members fence with the by-design reason. vm's refusal says why. - node:stream/web exports the web stream globals themselves. - node:dns/promises and dns.promises: lookup and lookupService as promises, in the link-gated scr_dns_promises.c unit. - eval and the Function constructor throw Node's EvalError under --disallow-code-generation-from-strings; the corpus harness runs the Node oracle with that flag for `// @disallow-code-generation`. - graceful-fs is served as node:fs. Every new lowering replaces a refusal, and the new runtime code links only when used, so other programs compile to identical bytes (zero-cost gate). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
740 B
JavaScript
19 lines
740 B
JavaScript
// @deferred-fences: 2
|
|
// The dd-trace shape: a module requires v8 at top level and touches its
|
|
// engine-observation members only on optional paths. Requiring it and
|
|
// destructuring members succeeds; getHeapStatistics answers.
|
|
const v8 = require("v8");
|
|
const { writeHeapSnapshot, setFlagsFromString } = require("node:v8");
|
|
|
|
console.log(typeof v8, typeof v8.getHeapStatistics);
|
|
const stats = v8.getHeapStatistics();
|
|
console.log(stats.heap_size_limit > 0, "used_heap_size" in stats);
|
|
|
|
function snapshot(enabled) {
|
|
if (enabled) return writeHeapSnapshot();
|
|
return "skipped";
|
|
}
|
|
console.log(snapshot(process.env.SCRIPTC_NEVER_SET === "1"));
|
|
if (process.env.SCRIPTC_NEVER_SET === "1") setFlagsFromString("--expose-gc");
|
|
console.log("done");
|