Fork me on GitHub

I’m having trouble requiring firebase 9 sdk using the :target :bundle approach, but I can successfully require using the :foreign-libs approach . Here is a Note: I am looking to use vanilla CLJS. • the contains the :target :bundle approach - does not work. :octagonal_sign: ◦ firebase throws an error Error: Component auth has not been registered yet • the branch contains the :foreign-library approach - works. I don’t want to make this about firebase, because I think this is a more general issue people might run into when using JS libs using ESM. My hunch is that it’s the way that firebase 9 sdk exports modules. They use a named module export e.g.

//------ firebase/auth.js ------
export { getAuth };
For further reference: •


Having said this. My second hunch is that they may be doing side effecting things.


might be webpack elimiating the firebase/auth import because as far is can see it is not used?


although unlikely given that is can't see anything else either


note that this is not vanilla CLJS. figwheel seems to be doing some webpack stuff? or I just can't find where you run webpack 😛


Figwheel just automates (tmk) what you would have to do manually here: so instead of configuring :bundle-cmd figwheel does that for you when you specify :auto-bundle :webpack


I will validate my assumption with a pure CLJS version


well if its just be basic thing it should be fine


Yeah. Same deal.


Maybe try repro without CLJS? I guess it’s the require from CLJS that causes this?


Okay. Added a with a pure JS example. Require statements seem to work.


Perhaps I need to try refactor the pure JS example to do exactly what CLJS does with npm_deps.js file though? e.g.

module.exports = {
  npmDeps: {
    "@firebase/auth": require('@firebase/auth'),
    "@firebase/app": require('@firebase/app')}
and then require that into the index.js file I have setup? :thinking_face:


Update: is a min repro of what cljs is doing, but in vanilla JS (assuming I understand). It seems to work just fine :thinking_face:


Okay, I think I see the problem, but my JS module foo is not strong enough to grok this ATM. When you run in JS

import { getAuth } from '@firebase/auth';
the above would import which would then import . platform_browser is going to invoke a function called registerAuth(ClientPlatform.BROWSER); The issue is that with how the import is happening in CLJS registerAuth never seems to be called :thinking_face:


@lee thanks for the pointers, I would prefer the non-static approach for the moment

👍 1

Hi, how should I include a cljc library into a clojurescript deps.edn project using shadow-cljs? I tried including it in the :deps of deps.edn but then shadow-cljs says the required namespace is not available. Is the general approach wrong?


I used {:local/root "../$LIBRARYNAME$"} as described in the


if you added the dependency correctly and it is on the classpath it should just work


note that adding via :local/root only works if the lib in question actually also has a deps.edn


Thanks, those are good pointers. It does have a deps.edn. I'm not sure if it's on the classpath but I'll check. Do I need to build a jar for this to work?


Just checked the docs again and it doesn't require a jar. That's an even different way of including libraries.


explaining classpath and so on


if you tell me which library you are trying to use and which ns I can check if it should work


Thanks! I'll take a look at the doc. It's lib I wrote myself.


I'm on my phone right now but I'll try it again when I'm at my computer tonight.


then assuming all paths are correct it should work


I'll double check the paths


This is my project setup:

├── client
│   ├── deps.edn
│   ├── shadow-cljs.edn
│   ├── [...stuff]
│   └── src
│       └── core.clj
└── csv
    ├── deps.edn
    ├── [...stuff]
    └── src
        └── csv.cljc
This is the client/deps.edn:
{:deps {org.clojure/clojurescript {:mvn/version "1.10.866"}
        csv/csv {:local/root "../csv"}}}
The csv lib is a bunch of functions with tests, so there's only tests in the deps.edn:
{:aliases {:test {:extra-paths ["test"]
                  :extra-deps {io.github.cognitect-labs/test-runner
                               {:git-url ""
                                :sha "9e35c979860c75555adaff7600070c60004a0f44"}}
                  :main-opts ["-m" "cognitect.test-runner"]
                  :exec-fn cognitect.test-runner.api/test}}}
This is almost exactly the same setup as in the [guide on local libs]( but it doesn't work.


I don't see any :paths?


also don't see shadow-cljs?


Yeah, I didn't add paths, that might be it. I'll change that. Here's the Although I have :source-paths in my client/shadow-cljs.edn :

{:source-paths ["src"]
 :dev-http {8081 "public"}
 :nrepl {:port 3333}
 :dependencies [[reagent "1.1.0"]
                [re-frame "1.2.0"]]
 :builds {:app {:target :browser
                :output-dir "public/scripts"
                :asset-path "/scripts"
                :modules {:core {:init-fn client.core/main}}}}} 


so you are not actually using deps.edn.

💡 1

to make shadow-cljs use deps.edn you need to add :deps true to shadow-cljs.edn and then remove :source-paths and :dependencies


those will then be mananged via deps.edn so you need to add them there as well as shadow-cljs itself


That makes total sense. Thanks!