just icon indicating copy to clipboard operation
just copied to clipboard

Allow importing from `node_modules` without having to specify `./node_modules` path

Open PaulRBerg opened this issue 4 months ago • 2 comments

It would be nice if we could write it like this:

import "@sablier/devkit/just/base.just"
import "@sablier/devkit/just/npm.just"

Instead of this:

import "./node_modules/@sablier/devkit/just/base.just"
import "./node_modules/@sablier/devkit/just/npm.just"

PaulRBerg avatar Oct 11 '25 16:10 PaulRBerg

just is not specifically a nodejs/npm tool, so it shouldn't treat node_modules specially. Can you think of a new generic just setting (i.e. not specific to any particular language or ecosystem) that you as justfile author could set to ./node_modules to enable this behavior?

One idea, although not sure whether this is quite what you're seeking:

# If an import path points to a nonexistant path: before erroring,
# try to resolve the import relative to ./node_modules first,
# and if that also fails, then try again relative to ~/.node_modules
set additional-import-search-paths := ['./node_modules', x'~/.node_modules']

But anything like this seems like a lot of effort. Does your production justfile have a lot of imports from node_modules?

laniakea64 avatar Oct 11 '25 17:10 laniakea64

Fair enough, I hear you about just not being a Node.js-first tool.

The additional-import-search-paths setting would be helpful!

Does your production justfile have a lot of imports from node_modules?

It's more that I have a bunch of *.just files in a shared repository that are imported by a bunch of other repos via node_modules:

  • https://github.com/sablier-labs/devkit/tree/d6cf3d33a1ce85d90e01f983dabd1c63d951f0ef/just
  • https://github.com/sablier-labs/lockup/blob/546e66b4ae624f5eea1383f229dbad4e949bbbf8/justfile
import "./node_modules/@sablier/devkit/just/evm.just"

PaulRBerg avatar Oct 12 '25 10:10 PaulRBerg