Skip to content

vendor_dirs takes precedence over lookup_paths #95

@ArtskydJ

Description

@ArtskydJ

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions