import { resolve } from 'path' ; import * as ts from 'typescript' ; /** Create compiler host based on the content of tsconfig. */ export function createCompilerHost ( config ) { const host = ts . createCompilerHost ( config . options , true ) ; if ( config . raw . bazel ) { const files = new Set ( config . fileNames . map ( p => resolve ( p ) ) ) ; const originalFileExists = host . fileExists ; host . fileExists = ( path ) : boolean => { if ( path . endsWith ( '.ts' ) && ! path . endsWith ( '.d.ts' ) ) { if ( ! files . has ( resolve ( path ) ) ) return false ; } return originalFileExists . call ( host , path ) ; } ; } return host ; }