This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-08
Channels
- # adventofcode (49)
- # babashka (21)
- # babashka-sci-dev (12)
- # beginners (250)
- # calva (23)
- # cider (6)
- # clj-kondo (11)
- # cljsrn (8)
- # clojure (129)
- # clojure-europe (50)
- # clojure-france (8)
- # clojure-italy (6)
- # clojure-nl (14)
- # clojure-romania (7)
- # clojure-spec (21)
- # clojure-uk (3)
- # clojurescript (17)
- # conjure (1)
- # core-async (40)
- # core-logic (24)
- # core-typed (7)
- # datavis (2)
- # datomic (2)
- # emacs (29)
- # fulcro (10)
- # graalvm (6)
- # graphql (24)
- # gratitude (6)
- # jobs (1)
- # lsp (9)
- # malli (6)
- # missionary (1)
- # nextjournal (46)
- # off-topic (2)
- # other-languages (3)
- # pathom (5)
- # portal (2)
- # re-frame (37)
- # remote-jobs (1)
- # shadow-cljs (15)
- # spacemacs (9)
- # testing (6)
- # tools-deps (13)
- # vim (32)
- # xtdb (16)
I have a script build with :js-options {:js-package-dirs ["functions/node_modules"]}
but when I run the script it can’t find modules that only exist in functions/node_modules
. I tried running the script from the functions directory and also tried compile
and release
(simple) builds.
The directory structure looks like this
• scripts/index.js
• functions/node_modules
• shadow-cljs.edn
remember that node build targets by default do not bundle their dependencies. so they need to be available at runtime using node resolve rules. in short that is <script-dir>/node_modules and <script-dir>/../node_modules and so on going up
if you want a fully self contained script that has no outside dependencies I recommend post processing with https://github.com/vercel/ncc
shadow-cljs can bundle deps too but all of it is optimized for the browser so ncc generally works better for node builds
but in general I would just recommend putting the :output-to
into the dir that also has the node_modules
dir
gotcha, yeah that makes sense then. I’ll try to just move the file into functions
. I did play with ncc
at some point which also worked pretty well but not really required in this case.
I somehow thought that the :js-package-dirs
option would magically tell the compiled script where to find packages but I think it’s slightly different / only has that effect for browser builds
yeah it only telle shadow-cljs where to find packages when bundling (which node targets don't do by default)
cool, it’s still used for node though is it? like for compile time warnings or stuff like that?