ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

compilerHost never reuses `SourceFile` instances

Open cspotcode opened this issue 5 years ago • 0 comments

I'm not sure if this is a bug or what. But if I hook into the CompilerHost's getSourceFile function, it never reuses a pre-existing SourceFile. It always returns new ones. This implementation of getSourceFile is provided by ts.createIncrementalCompilerHost.

Are we meant to wrap the CompilerHost to implement caching ourselves? Does TypeScript do this sort of wrapping internally?

I've definitely looked at those parts of the TS codebase before, but I forget, so I'll need to look again.

LanguageService does this automatically via DocumentRegistry. The CompilerHost APIs don't have a way to pass in a DocumentRegistry.

cspotcode avatar Aug 12 '20 21:08 cspotcode