Fork me on GitHub

I'm having some trouble with :npm-deps. Seems to install everything fine, but when I go to require it I get Uncaught Error: Undefined nameToPath for video.js


I've tried using (:require [video.js], (:require [video.js :as videojs]), and (:require ["video.js" :as videojs])


i got it working with another library, so i'm wondering if it might have something to do with the period in the library name.


app:cljs.user=> (:require video.js)
#object[ReferenceError ReferenceError: video is not defined]


@vheuken At the REPL, you'd type

(require 'video.js)


(The :require variant is used in ns forms.)


i have a cljs project that includes a dependency from npm like so and everything compiles fine:

{:npm-deps {:highlight.js "9.12.0"} :install-deps true} i also have a larger project that includes this cljs project as a dependency, however the parent project fails to build because the node module doesn't install itself:
Failed to compile "resources/public/js/compiled/app.js" in 22.878 seconds.
----  Could not Analyze  resources/public/js/compiled/im_tables/views/dashboard/manager/codegen/main.cljs  ----
  No such namespace: highlight.js, could not locate highlight/js.cljs, highlight/js.cljc, or JavaScript source providing "highlight.js" 
i've tried adding :install-deps true to the parent project's build configuration with no luck. any ideas? 🙂


(both projects are on the same version of clojure and clojurescript)


@joshkh The library only has :npm-deps defined on project.clj? That won't have any effect on apps using the library, Lein options (like cljsbuild) don't work like that.


hmm yeah, i didn't think they would. if a library has project level deps then they're installed when that project is required elsewhere. npm deps are defined at the cljsbuild level and so they don't bubble out.


I'd recommend just adding both :npm-deps and :install-deps to the parent project, then it is obvious that the specified npm dependency will be used.


However, this is probably not documented anywhere currently, but you can define :npm-deps on library's deps.cljs file (same place where foreign libs define :externs etc.) and that will be read by Cljs compiler when using :install-deps


that's what i ended up doing. it feels a little hacky though, yeah? you have to know that one of your dependencies has a node dependency, then manually lift it up into your project.


oh interesting. i'll look into that 🙂 thanks


How can I a turn on instrumentation of all fdef-ed functions? seems to be removed?


We have one init function for dev and one for prod. I put this in the init function for dev:

(s/check-asserts true)
Does that make sense?


@borkdude FWIW, ClojureScript is a little behind Clojure with respect to precisely how stest/instrument behaves, but I suspect it won't matter for common use cases. Captured here


as long as I’m getting an error I’m fine


refactoring is easier that way


Has anyone here successfully used a react component with :npm-deps/:install-deps compiler options?


As far as I can tell cljsbuild does absolutely nothing when it is given those options


@bfast I’ve spent many hours trying and failed and never found anybody who could help me. The three approaches that seem to reliably work with the current state of the art are (1) :foreign-libs (2) the “double bundle” approach with webpack, (3) shadow-cljs. I prefer (3) because you just install stuff using npm and import directly, but some people would prefer to stay with their familiar lein/boot setup.


perhaps compiling the react component I want with webpack and then adding it as a foreign lib is the easiest way


I have to say, this is a huge miss in the CLJS world... If I figure this out I am definitely writing a tutorial


definitely check out shadow-cljs. it solved a lot of my pain points. as for :npm-deps I understand there are lots of improvements in the pipeline.


Thanks. Shadow-cljs isn't really an ideal option at this point because the rest of the project is tied into leiningen


@bfast shadow-cljs works fine from inside leiningen 😉

Roman Liutikov19:03:27

I found “double bundle” is a good approach when you have shared JS dependencies between multiple cljs projects. Browser caches js bundle once and all apps can reuse this dependency from the cache.


Beginner here!


With garden am I supposed to have a .css file output?


If so, how?