@@ -35,7 +35,7 @@ import stableStringify = require('fast-json-stable-stringify')
3535import { readFileSync , writeFileSync } from 'fs'
3636import memoize = require( 'lodash.memoize' )
3737import mkdirp = require( 'mkdirp' )
38- import { basename , extname , join , relative } from 'path'
38+ import { basename , extname , join , normalize , relative } from 'path'
3939
4040import { ConfigSet } from './config/config-set'
4141import { MemoryCache , TsCompiler , TypeInfo } from './types'
@@ -136,7 +136,8 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
136136 const serviceHost = {
137137 getScriptFileNames : ( ) => Object . keys ( memoryCache . versions ) ,
138138 getScriptVersion : ( fileName : string ) => {
139- const version = memoryCache . versions [ fileName ]
139+ const normalizedFileName = normalize ( fileName )
140+ const version = memoryCache . versions [ normalizedFileName ]
140141
141142 // We need to return `undefined` and not a string here because TypeScript will use
142143 // `getScriptVersion` and compare against their own version - which can be `undefined`.
@@ -146,14 +147,15 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
146147 return version === undefined ? ( ( undefined as any ) as string ) : String ( version )
147148 } ,
148149 getScriptSnapshot ( fileName : string ) {
149- const hit = hasOwn . call ( memoryCache . contents , fileName )
150- logger . trace ( { fileName, cacheHit : hit } , `getScriptSnapshot():` , 'cache' , hit ? 'hit' : 'miss' )
150+ const normalizedFileName = normalize ( fileName )
151+ const hit = hasOwn . call ( memoryCache . contents , normalizedFileName )
152+ logger . trace ( { normalizedFileName, cacheHit : hit } , `getScriptSnapshot():` , 'cache' , hit ? 'hit' : 'miss' )
151153 // Read contents from TypeScript memory cache.
152154 if ( ! hit ) {
153- memoryCache . contents [ fileName ] = ts . sys . readFile ( fileName )
155+ memoryCache . contents [ normalizedFileName ] = ts . sys . readFile ( normalizedFileName )
154156 }
155157
156- const contents = memoryCache . contents [ fileName ]
158+ const contents = memoryCache . contents [ normalizedFileName ]
157159 if ( contents === undefined ) {
158160 return
159161 }
0 commit comments