gadfly361 / rid3

Reagent Interface to D3
MIT License
142 stars 6 forks source link

"d3 is not defined error" when starting out #16

Closed kovasap closed 2 years ago

kovasap commented 3 years ago

Hey I'm just getting started with this library with my project at https://github.com/kovasap/reddit-tree/commit/09a4cd0f8e3e3913d18a2571ecc566a9741e85b9. I'm getting these errors in my console when trying to run npx shadow-cljs watch app:

image

I've installed d3 with npm install d3, and it looks like it's present in my node_modules. Any ideas what I might be doing wrong here?

gadfly361 commented 3 years ago

@kovasap rid3 brings it's own version of d3 so having another copy can create a conflict. Can you try removing your manual install and trying again?

kovasap commented 3 years ago

Hmm, then I get:

> npx shadow-cljs watch app

shadow-cljs - config: /home/kovas/reddit-tree/reddit-tree/shadow-cljs.ednshadow-cljs - HTTP server available at http://localhost:3000
shadow-cljs - server version: 2.15.5 running at http://localhost:9630
shadow-cljs - nREPL server started on port 45557
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required JS dependency "d3" is not available, it was required by "cljsjs/d3.cljs".

Dependency Trace:
    reddit_tree/core.cljs
    rid3/core.cljs
    rid3/viz.cljs
    rid3/main_container.cljs
    cljsjs/d3.cljs

Searched for npm packages in:
    /home/kovas/reddit-tree/reddit-tree/node_modules

See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install
gadfly361 commented 3 years ago

@kovasap Rid3 was made back when cljsjs had a lot more traction (i.e. rid3 pulls in d3 using cljsjs). Shadow-cljs doesn't like cljsjs packages, but it appears shadow-cljs provides work arounds, see the links below:

1) https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs 2) https://github.com/thheller/shadow-cljsjs

kovasap commented 2 years ago

Hmm ok, thanks for the pointers. It still doesn't seem to work for me; I reached out on the shadow-cljs side at https://github.com/thheller/shadow-cljsjs/issues/19. I really hope this will work, since this library looks like it does what I want in my reading so far. In case it doesn't, or my project changes, do you know of other cljs d3 libraries that are worth checking out? Or is rid3 the only real option for adding d3 to a reagent app?

kovasap commented 2 years ago

Everything is working for me now, thanks for the help!