mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-14 20:25:26 +02:00
Carry forward PR #3115ef475c79and780dfb78onto current main. Preserve the newer hook-consent transforms during install and repair. Main already includes the source import fix from #3167.
19 lines
654 B
JavaScript
19 lines
654 B
JavaScript
import { readFile } from "node:fs/promises"
|
|
import ts from "typescript"
|
|
|
|
// Emulate OpenCode's in-place TypeScript loading without remapping missing
|
|
// .js specifiers to .ts files. Such remapping would hide issue #3112.
|
|
export async function load(url, context, nextLoad) {
|
|
if (!url.endsWith(".ts")) return nextLoad(url, context)
|
|
|
|
const source = await readFile(new URL(url), "utf8")
|
|
const result = ts.transpileModule(source, {
|
|
compilerOptions: {
|
|
target: ts.ScriptTarget.ES2022,
|
|
module: ts.ModuleKind.ESNext,
|
|
verbatimModuleSyntax: true,
|
|
},
|
|
})
|
|
return { format: "module", source: result.outputText, shortCircuit: true }
|
|
}
|