This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-14
Channels
- # announcements (3)
- # babashka-sci-dev (22)
- # beginners (6)
- # calva (36)
- # cljsrn (1)
- # clojure (59)
- # clojure-europe (31)
- # clojure-france (3)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-uk (4)
- # clojurescript (6)
- # conjure (1)
- # cursive (11)
- # data-oriented-programming (1)
- # datahike (2)
- # docker (8)
- # duct (4)
- # emacs (1)
- # figwheel-main (5)
- # kaocha (1)
- # leiningen (8)
- # lsp (64)
- # malli (10)
- # membrane (5)
- # nrepl (11)
- # off-topic (5)
- # portal (6)
- # quil (9)
- # reagent (62)
- # reitit (15)
- # releases (3)
- # ring-swagger (2)
- # shadow-cljs (36)
- # specter (2)
- # tools-deps (21)
I have a cljs project (`first project`) with the following shadow-cljs.edn -
{:source-paths
["src"]
:dependencies
[[re-frame "1.3.0-rc3"]
[com.degel/iron "0.4.0"]]
:builds
{:library
{:target :node-library
:output-to "out/re_frame_firebase.js"
:exports {:initializeApp com.degel.re-frame-firebase.core/initialize-app}}}}
This project is imported as an npm dependency in another project's (`second project`) package.json. On npm install
the first project's npm module gets installed successfully.
When I run the second project with shadow-cljs watch app
this is the error I get -
[:app] Build failure:
The required JS dependency "re-frame-firebase/out" is not available, it was required by "app/fb/init.cljs".
I have checked the the npm_modules of the second project -
$ ls node_modules/re-frame-firebase/out
re_frame_firebase.js
Why cant the second project find the above dependency, what am I doing wrong ?How can I call a function in a dynamically loaded module? Edit: nevermind; resolve
did the trick
@murtaza52 you absolutely should not be including a compiled CLJS build in another CLJS build. just include the sources directly instead
@wombawomba how are you loading the module? avoid resolve
if you can, it is not ideal.
https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841
@thheller I'm using shadow.loader/load
shadow.lazy
looks really useful — thanks!
you should include it in the user's guide
https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html is also an option
@thheller this is a third party library (`re-frame-firebase`), that we are using in a project. We had to fork it make changes to it. (we converted it to a shadow-cljs project) Now I am having trouble using it in my project ? As you suggested include the sources, you mean just copy all the sources in the project, or is there a better way ? (bcoz that will defeat the purpose behind having libraries)
many options, dunno what exactly you need but I including a compiled version is definitely the last thing you should be doing
if the changes you made are only done for your second project
it is fine to include the sources directly too. no point in writing libraries with exactly one consumer 😉
@thheller thanks that is what we were trying to do - include it from a local directory
this is the dep entry in package.json for the second project
"re-frame-firebase": "file:../re-frame-firebase",
and npm install
includes the compiled version along with sources under the node_modules
no, that is not what you are doing. I mean yes, but you are trying to include the wrong thing
you can do so via shadow-cljs.edn
by adding :source-paths ["src" "../that-library/src"]
@thheller thanks for that blog post. It's pretty much exactly what I was trying to build :)
or publishing that modified lib to clojars (pretty easy if it is already using leiningen)
aah so I should never use it via package.json
through npmjs
. But why at the end its a regular js file, how does it matter if I distribute it via clojars (jar) or npmjs (node module) ?
the compiled version will include its own version of firebase, reframe, cljs.core and whatever else it is using. it will not be compatible with the one you are using in your project.
ok thanks.
so If I do a lein install
on the re-frame-firbase
(first project), the jar will just include the sources, and then the shadow-cljs in the second-project
will compile it to js ?
I’ve tried this:
(defmacro defoo [name]
`(def ^:export ~name 42))
but inspecting the output (I’m targeting :npm-module
) the resulting def doesn’t appear to be exported:
(defoo bar)
compiles to
myns.bar = (42);
Object.defineProperty(module.exports, "bar", { enumerable: false, get: function() { return myns.bar; } });