-
Notifications
You must be signed in to change notification settings - Fork 24
Description
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 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?
- Sublime's
Ctrl+P, "File: Reveal in Sidebar"doesn't work with the first - My
.eslintignorefile ignores node_modules, and I want linting on files in my project - 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?