Skip to content

Limit the scope of file and directory searching when resolving modules #801

Open

Description

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?

  • Android
  • iOS
  • macOS
  • Windows

System Information

N/A

Steps to Reproduce

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    • Status

      🌳 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions