Skip to content

Commit

Permalink
fix(compiler): make sure language service use updated compiler options
Browse files Browse the repository at this point in the history
The compiler options are updated to have the proper module kind and are used by `_transpileOutput`.
But when the compilation is delegated to the language service, the updated compiler options are not used,
and the module kind ends up being the one in the initially read configuration.

To make sure the language service gets the updated compiler options,
this commit bumps the project version, thus ensuring that the internal `synchronizeHostData`
of the language service refresh the options.
(see https://github.com/microsoft/TypeScript/blob/459bd1994115fc4a14f7f1a80c36affe2281f2ea/src/services/services.ts#L1278-L1287)
  • Loading branch information
cexbrayat committed May 26, 2021
1 parent c568f49 commit c844f43
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/ts-compiler.ts
Expand Up @@ -170,7 +170,8 @@ export class TsCompiler implements TsCompilerInstance {
}
if (this._languageService) {
this._logger.debug({ fileName }, 'getCompiledOutput(): compiling using language service')

// Make sure the language service gets the updated compiler options
this._projectVersion++
// Must set memory cache before attempting to compile
this._updateMemoryCache(fileContent, fileName)
const output: EmitOutput = this._languageService.getEmitOutput(fileName)
Expand Down

0 comments on commit c844f43

Please sign in to comment.