| 1 | import assert from "node:assert/strict" |
| 2 | import * as Module from "node:module" |
| 3 | |
| 4 | if (Module.registerHooks !== undefined) { |
| 5 | Module.registerHooks({ |
| 6 | resolve(specifier, context, nextResolve) { |
| 7 | const resolved = nextResolve(specifier, context) |
| 8 | assert.doesNotMatch( |
| 9 | resolved.url, |
| 10 | /\/(?:internal\/schema\/(?:codegen|jitCompiler)|unstable\/schema\/Schema(?:AOT|JIT)Compiler)(?:\.|\/)/, |
| 11 | "Generated modules must not load source generation or the JIT compiler" |
| 12 | ) |
| 13 | return resolved |
| 14 | } |
| 15 | }) |
| 16 | } else { |
| 17 | Object.defineProperty(globalThis, "Function", { |
| 18 | value: function() { |
| 19 | throw new EvalError("Code generation from strings disallowed") |
| 20 | } |
| 21 | }) |
| 22 | } |