Skip to content

Commit

Permalink
feat : support build option of tsc in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlb authored and fi3ework committed Feb 6, 2022
1 parent ccd1ef5 commit 7a0316a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions packages/vite-plugin-checker/src/checkers/typescript/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,22 @@ const createDiagnostic: CreateDiagnostic<'typescript'> = (pluginConfig) => {
// https://github.com/microsoft/TypeScript/pull/33082/files
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram

const host = ts.createWatchCompilerHost(
configFile,
{ noEmit: true },
ts.sys,
createProgram,
reportDiagnostic,
reportWatchStatusChanged
)

ts.createWatchProgram(host)
if (typeof pluginConfig.typescript === 'object' && pluginConfig.typescript.buildMode) {
const host = ts.createSolutionBuilderWithWatchHost(ts.sys, createProgram, reportDiagnostic, undefined, reportWatchStatusChanged)

ts.createSolutionBuilderWithWatch(host, [configFile], {}).build()
} else {
const host = ts.createWatchCompilerHost(
configFile,
{ noEmit: true },
ts.sys,
createProgram,
reportDiagnostic,
reportWatchStatusChanged
)

ts.createWatchProgram(host)
}
},
}
}
Expand Down

0 comments on commit 7a0316a

Please sign in to comment.