cursive
cursive copied to clipboard
Resolve dependencies off package.json directly (better shadow-cljs support)
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
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.
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)
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.
IntelliJ has a NodeJS plugin. Is it somehow possible for Cursive to hook into that?
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 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.