import { resolve as resolvePath } from 'path' ; import ts from 'typescript' ; import { reportDiagnostic , reportSolutionBuilderStatus } from './Logging/index' ; import { tsSys } from './tsSystem' ; param srcStr param watch export async function buildPath ( srcStr , watch = false ) { const srcPath = resolvePath ( srcStr ) ; let tsConfigPath = ts . findConfigFile ( srcPath , ts . sys . fileExists , 'tsconfig.json' ) ; if ( ! tsConfigPath ) tsConfigPath = resolvePath ( 'tsconfig.json' ) ; /**
     * TypeScript Program to use
     */ const createProgram = ts . createSemanticDiagnosticsBuilderProgram ; if ( watch ) { const host = ts . createWatchCompilerHost ( tsConfigPath , { } , tsSys , createProgram ) ; ts . createWatchProgram ( host ) ; } else { const host = ts . createSolutionBuilderHost ( tsSys , undefined , reportDiagnostic , reportSolutionBuilderStatus ) ; const solution = ts . createSolutionBuilder ( host , [ tsConfigPath ] , { verbose : true , } ) ; solution . build ( srcStr ) ; } }