t3-code-android-nightly/.repos/effect-smol/packages/effect/test/schema/fixtures/aot-import-guard.ts
Julius Marminge 6f9cea00ae
chore(refs): sync Effect and Alchemy references to 4.0.1 and beta.80 (#16170)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 13:22:30 -07:00

22 lines
695 B
TypeScript

import assert from "node:assert/strict"
import * as Module from "node:module"
if (Module.registerHooks !== undefined) {
Module.registerHooks({
resolve(specifier, context, nextResolve) {
const resolved = nextResolve(specifier, context)
assert.doesNotMatch(
resolved.url,
/\/(?:internal\/schema\/(?:codegen|jitCompiler)|unstable\/schema\/Schema(?:AOT|JIT)Compiler)(?:\.|\/)/,
"Generated modules must not load source generation or the JIT compiler"
)
return resolved
}
})
} else {
Object.defineProperty(globalThis, "Function", {
value: function() {
throw new EvalError("Code generation from strings disallowed")
}
})
}