import * as T from "./types" ; import * as requireFromString from "require-from-string" ; import stringHash = require ( "string-hash" ) ; export function fromFs < T = unknown > ( fs ) { return < V = T > ( sourceFile , filename ? ) : V => getExports < V > ( String ( fs . readFileSync ( sourceFile ) ) , filename || sourceFile ) ; } const exportsCache = new Map ( ) ; function getExports < T > ( source , filename ) { const hash = stringHash ( source ) ; if ( ! exportsCache . has ( hash ) ) { exportsCache . set ( hash , requireFromString ( source , filename ) ) ; } return exportsCache . get ( hash ) ; }