rnx-kit
rnx-kit copied to clipboard
Limit the scope of file and directory searching when resolving modules
What happened?
findModuleFile
: When combining searchDir
and modulePath
, don't let the result "escape" the confines of searchDir
. If that happens, return undefined
indicating a module resolution failure.
findPackageDependencyDir
(local to resolve.ts): Add a stopDir
parameter to limit the scope of the search to the current repository. Don't let the search go all the way to the root of the file system. Other resolvers don't do this because it violates the algorithm, but it's reasonable for us since we know node_modules
will only legitimately be in the repo based on the way npm, yarn, pnpm, and other major package managers work (even if node_modules is a bunch of symlinks).
Affected Package
@rnx-kit/typescript-react-native-resolver
Version
Which platforms are you seeing this issue on?
- [X] Android
- [X] iOS
- [X] macOS
- [X] Windows
System Information
N/A
Steps to Reproduce
N/A
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
FYI https://github.com/microsoft/rnx-kit/tree/main/packages/typescript-react-native-resolver is deprecated, now findPackageDependencyDir
are under https://github.com/microsoft/rnx-kit/tree/main/packages/tools-node
(findModuleFile
has been removed entirely)