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

vendor_dirs takes precedence over lookup_paths #95

Open
ArtskydJ opened this issue Jul 11, 2022 · 0 comments
Open

vendor_dirs takes precedence over lookup_paths #95

ArtskydJ opened this issue Jul 11, 2022 · 0 comments

Comments

@ArtskydJ
Copy link
Contributor

Situation

In a JavaScript monorepo project:

- /api
- /scripts
- (etc.)
- /shared

I want to easily import shared code from /shared into the other directories. So there are symlinks set up:

- /api/src/node_modules/shared -> /shared
- /scripts/node_modules/shared -> /shared
- (etc.)

HyperClick's default behavior

HyperClick opens /scripts/node_modules/shared/whatever-file.js when I click on require('shared/whatever-file.js').

I consider this to be expected behavior, but it's not the behavior that I want.

I want /shared/whatever-file.js to open.

Unexpected behavior with my attempted workaround

// HyperClick Settings - User
{
    "scopes": {
        "source.js | source.jsx | source.ts | source.tsx | source.mjs | source.cjs": {
            // ...
            "lookup_paths": [ "./" ],
            "vendor_dirs": [ "node_modules" ]
        }
    }
}

HyperClick seems to prioritize the vendor_dirs above lookup_paths, so HyperClick continues to open /scripts/node_modules/shared/whatever-file.js.

Changing the workaround

If I change my HyperClick Settings file

-             "vendor_dirs": [ "node_modules" ]
+             "vendor_dirs": []

this works! If I click on require('shared/whatever-file.js'), HyperClick opens /shared/whatever-file.js.

But now HyperClick doesn't know about node_modules, which was a nice feature.

Why it matters which path opens

The /shared/whatever-file.js file, and the /scripts/node_modules/shared/whatever-file.js file are the same file on disk, so why do I care that the first is opened instead of the second?

  1. Sublime's Ctrl+P, "File: Reveal in Sidebar" doesn't work with the first
  2. My .eslintignore file ignores node_modules, and I want linting on files in my project
  3. I'll sometimes have both paths of the file open simultaneously, which is confusing

How to solve

I hope that prioritizing lookup_paths over vendor_dirs would solve my problem, and hopefully not cause issues for anyone else. (Maybe my mental model is wrong, and lookup_paths/vendor_dirs don't have a peer relationship?)

Or maybe you can think of a better solution/workaround?

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

No branches or pull requests

1 participant