(content: string, options?: {strictTemplates?: boolean})
| 27 | import {resolveWasmBinding} from './utils.js'; |
| 28 | |
| 29 | async function setupCompiler(content: string, options?: {strictTemplates?: boolean}) { |
| 30 | const projectRoot = process.cwd(); |
| 31 | const filePath = join(projectRoot, 'test.ts'); |
| 32 | const tsconfigPath = join(projectRoot, 'tsconfig.json'); |
| 33 | const nodeModulesPath = join(projectRoot, 'node_modules'); |
| 34 | |
| 35 | const virtualFiles = { |
| 36 | [filePath]: content, |
| 37 | [tsconfigPath]: JSON.stringify({ |
| 38 | files: [filePath], |
| 39 | }), |
| 40 | }; |
| 41 | |
| 42 | const wasmBinding = resolveWasmBinding(); |
| 43 | const analyzer = await createAnalyzer(tsconfigPath, { |
| 44 | virtualFiles, |
| 45 | optimize: true, |
| 46 | backend: 'wasm', |
| 47 | wasmBinding, |
| 48 | nodeModulesPathOverride: nodeModulesPath, |
| 49 | }); |
| 50 | |
| 51 | const compiler = new HybridCompiler(analyzer, { |
| 52 | optimize: true, |
| 53 | tcbConfig: buildTypeCheckingConfig({strictTemplates: options?.strictTemplates ?? false}), |
| 54 | }); |
| 55 | |
| 56 | return {compiler, filePath}; |
| 57 | } |
| 58 | |
| 59 | async function setupMultiFileCompiler( |
| 60 | files: Record<string, string>, |
no test coverage detected