ts-node
ts-node copied to clipboard
compilerHost never reuses `SourceFile` instances
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.