mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
- Lowering rationale names the idiom; one user-facing hint reworded - Diagnostics snapshot re-pinned to the neutral hint text
11 lines
564 B
TypeScript
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")));
|