vite-esbuild-typescript-checker
Version:
* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking * Supports [Vue Single File Component](https://vuejs.org/v2/guide/single-file-components.html) * Displays nice error messages with the [code frame](https://babeljs.io/docs/en/
38 lines (37 loc) • 1.86 kB
JavaScript
import ts from 'typescript';
import { getSystem } from '../system.js';
import { getVueExtension } from '../vue/type-script-vue-extension.js';
import { workerOptions } from '../worker.js';
export function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate) {
const system = getSystem();
const typescriptVueExtension = getVueExtension();
const baseWatchCompilerHost = ts.createWatchCompilerHost(parsedConfig.fileNames, parsedConfig.options, system, createProgram, reportDiagnostic, reportWatchStatus, parsedConfig.projectReferences);
let controlledWatchCompilerHost = {
...baseWatchCompilerHost,
createProgram (rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
compilerHost = typescriptVueExtension.extendCompilerHost(compilerHost, parsedConfig);
return baseWatchCompilerHost.createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences);
},
afterProgramCreate (program) {
if (afterProgramCreate) {
afterProgramCreate(program);
}
},
onWatchStatusChange () {
// do nothing
},
watchFile: system.watchFile,
watchDirectory: system.watchDirectory,
setTimeout: system.setTimeout,
clearTimeout: system.clearTimeout,
fileExists: system.fileExists,
readFile: system.readFile,
directoryExists: system.directoryExists,
getDirectories: system.getDirectories,
realpath: system.realpath
};
if (workerOptions.vue?.enabled) {
controlledWatchCompilerHost = typescriptVueExtension.extendWatchCompilerHost(controlledWatchCompilerHost, parsedConfig);
}
return controlledWatchCompilerHost;
}