Description
In looking into TS compiler's resolver code, I have discovered an internal property called originalPath
in the ResolvedModuleFull
type returned by the resolveModuleName
API function. This is the function we rely on to get our resolved path for output.
Looking further into the code, it seems that the originalPath
value is set when the compilerOptions.preserveSymlinks
option is false
in tsconfig.json
and the resolved module is a symlink.
At present, if a resolved module is a symlink, our transformer output will use the symlink path as opposed to the original, which could cause issues. To mitigate, we should prefer originalPath
(when it is available) to avoid this issue.
Simply put, this will keep us from "following" symlinks during our own resolution.