(filename: string)
| 83 | constructor(readonly codeByFilename: {[filename: string]: string}) {} |
| 84 | |
| 85 | evaluateModule(filename: string): unknown { |
| 86 | if (filename in this.moduleExportsCache) { |
| 87 | return this.moduleExportsCache[filename]; |
| 88 | } |
| 89 | const exports = {}; |
| 90 | this.moduleExportsCache[filename] = exports; |
| 91 | const code = this.codeByFilename[filename]; |
| 92 | if (!code) { |
| 93 | throw new Error(`Did not find file ${filename}`); |
| 94 | } |
| 95 | const compiledCode = transform(code, {transforms: ["imports"]}).code; |
| 96 | vm.runInNewContext(compiledCode, {require: this.evaluateModule.bind(this), exports}); |
| 97 | return exports; |
| 98 | } |
| 99 | } |
no test coverage detected