Files
scriptc/tests/diagnostics/create-require.ts
T
Chris Tate b5f6b0dc46 Cite patterns, not target projects, across comments and hints
- Lowering rationale names the idiom; one user-facing hint reworded
- Diagnostics snapshot re-pinned to the neutral hint text
2026-07-23 01:18:50 -05:00

11 lines
564 B
TypeScript

// node:module ADMITS (the builtin import carries no evaluation), and every
// member keeps a per-site fence: createRequire loads CommonJS from disk at
// RUNTIME (the config/plugin-loading pattern), which a compiled program —
// whose modules are fixed at build time — cannot do. In TS sources the
// fence is this compile-time diagnostic; in JS sources the same call
// defers to a catchable runtime error naming the member.
import { createRequire } from "node:module";
const req = createRequire("/tmp/parent.js");
console.log(String(req("./config.cjs")));