Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect fileCkeckExists option, even when we have a host #30

Closed
wants to merge 2 commits into from

Conversation

Photonios
Copy link

This is needed in case you're using this transformer with ts.transpileModule. In which case, isolatedModules=true.

TypeScript specifies a one-off function that only returns the source for the module we're currently transpiling. This means that getSourceFile will only return true for the module being transpiled. This can be worked around by setting fileCkeckExists to true, but this option is not respected when there is a program and therefor a host.

A practical example where this problematic is ts-jest with the isolatedModules option set to true. See: https://github.com/kulshekhar/ts-jest/blob/v25.2.0/src/compiler.ts#L98 In this case, ts-jest uses ts.transpileModule and without the fileCkeckExists option properly working, transformation won't happen.

@Photonios
Copy link
Author

@zerkalica any chance you can have a look this? :)

@zerkalica
Copy link
Owner

Main goal of this manipulations with getSourceFile - reduce file system queries. Does host.fileExists cache it?

@Photonios
Copy link
Author

Photonios commented Apr 4, 2020

Main goal of this manipulations with getSourceFile - reduce file system queries. Does host.fileExists cache it?

Yes, see here:

https://github.com/microsoft/TypeScript/blob/5e9c43607f8732bc94374c95fddd8b1fd9881122/src/compiler/program.ts#L204

This is used unless the user disables caching.

@zerkalica
Copy link
Owner

Try 1.7.16, i remove getSourceFile

@Photonios Photonios closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants