microsoft/rushstack

[heft-typescript] Bound current directory in sys.watchFile and sys.watchDirectory

dmichon-msft opened this issue · 0 comments

Summary

The built-in ts.sys watchFile and watchDirectory methods bind process.cwd() at the moment of instantiation. This inhibits the ability of heft-typescript-plugin to change working directories between compilations (mostly relevant if running as a service).

Repro steps

Not reproducible via CLI. Happens when attempting to leverage Heft as an API to conserve system resources.

Details

See comment here:
https://github.com/microsoft/rushstack/blob/8fe0ea8f861a1cecd8b964bcdabc610f2a5574e3/heft-plugins/heft-typescript-plugin/src/TypeScriptBuilder.ts#L313C1-L313C58

The watchFile and watchDirectory methods need to be rebound to reflect the custom getCurrentDirectory() call. Might be worth reaching out to TypeScript to make the method that creates ts.sys publicly callable.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/heft-typescript-plugin version? 0.4.0
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? v18.19.1