cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Resolve dependencies off package.json directly (better shadow-cljs support)

Open binarykitchen opened this issue 4 years ago • 6 comments

Has anyone ever managed to resolve npm dependencies installed by shadow-cljs in cursive?

Cursive always displays these as

“x cannot be resolved”.

This because the npm dependencies are in package.json but not project.clj - Cursive seems to only scan those in project.clj. Thoughts?

PS: shadow-cljs pom and importing this via Maven didn't work

binarykitchen avatar Mar 05 '20 22:03 binarykitchen

Note that package.json is completely irrelevant when it comes to resolving stuff. shadow-cljs never looks at it for the regular project. Only the contents of the node_modules folder are considered and not how they got there.

thheller avatar Mar 06 '20 09:03 thheller

npm deps don't seem to resolve, and it would be really useful if they did - I get a lot of "cannot be resolved" false positives for things required using shadow's syntax:

["@material-ui/icons/Stars" :default Stars]
["@material-ui/icons" :as mui-icons]
["@material-ui/pickers" :refer [KeyboardDatePicker]]

In this example, cursive can resolve neither Stars, mui-icons/Stars nor KeyboardDatePicker, but they are all valid require syntax (although they will only resolve after an npm install or whatever the yarn equivalent is)

conan avatar Mar 30 '20 16:03 conan

Yes, especially when working with react-bundling apps like reagent / re-frame / om.next / fulcro this is an Issue often encountered. Our team would really appreciate a feature, that takes this into account.

Wegi avatar Aug 18 '20 06:08 Wegi

IntelliJ has a NodeJS plugin. Is it somehow possible for Cursive to hook into that?

devurandom avatar Jun 18 '23 19:06 devurandom

It's possible to hook into it's package.json support, yes, but that doesn't supply the exports from those packages. That is provided by the JS support, and that is very hard to integrate with. I've made several attempts, but it relies on the source looking very much like JS, unfortunately.

cursive-ide avatar Jun 19 '23 21:06 cursive-ide

@cursive-ide Maybe not actually resolved if it's so hard, but what about an option to treat them as defined symbols for the current file?

e.g.

["react" :as react]

Would be the same as:

(def react nil) ;; nil or whatever

and similar for

["@mui/material" :refer [CardActionArea]]

So that we don't get those annoying warnings.

This could be an option that can be toggled, I personally work a lot using ClojureScript, and it'd be really good to not mark them as warnings.

ulisesmac avatar Jan 09 '24 18:01 ulisesmac