Fork me on GitHub

when you require it from the ns :require it will become part of the shadow-cljs build


when you js/require it then it will just resolve at runtime and not be part of the build


Yes, that works. Whereas before I wasn't trying to make shadow bundle things, I later wanted to see if I could get shadow bundling everything as you mentioned in that ticket. I've been reading stuff you said there multiple times and understanding more and more 😄. > Just stick with :node-library. :esm will not give you any "new" features if it requires post-processing anyways. So until vscode can load ESM directly without further bundling :esm should not be used. I'm sticking to :node-library but was thinking I could still bundle things with shadow if I could make typescript ignore the goog:.. imports, as you mentioned, and then stop using webpack. But I see you mentioned potential issues with that, so I probably will stop this approach now.


yeah I'd recommend sticking with js/require until you get the amount of JS code down significantly


That makes sense


its fine for smaller bits of JS code or JS code that is fully advanced compatible


but for the vast chunk of the vscode based code you probably won't have externs anyways


I mean you can still go with this route and try it


but not many people do so there may be many issues with this that may require tinkering with shadow-cljs


it works ok-ish in the browser but node seems to have some problems


Yeah, I'd rather go the path of least resistance in this case

Kira McLean04:02:29

Has anyone built a custom shadow-cljs build target before? Is this actually possible? I spotted this in the shadow-cljs docs: > The build target is an extensible feature of `shadow-cljs` but am still looking for details about how it might be done :thinking_face: .. wondering if there are any examples out there

Kira McLean04:02:20

I would like to make a build target that combines devcards and karma (basically combine the current built-in :browser and :karma build targets), so I can use devcards as a test harness for UI-based cljs tests


@kiraemclean I guess as example you could look at the default provided targets, they all use the same mechanism a custom target would use.

Kira McLean14:02:37

this is very helpful, thank you for the reply! I didn’t know the :karma target could take a runner-ns option, I think that would do it! I was looking at using a custom runner-ns for the existing browser-target then some karma hackery to get it to run in CI, but I think doing it the other way around (starting with the existing karma target and adding a custom runner) would be simpler.

Kira McLean14:02:40

I was wading through the custom targets but didn’t figure out how to build a custom one that could hook in to the existing build chain.


they all function based on the same principle. when shadow-cljs finds :target :karma in the build config it'll "expand" :karma to and call that function for every "stage" of the compilation.


so if you were to create a :target :kira you'd create that function and do whatever you want to do


it it also valid to have :target which would call ( build-state) or :target which would call ( build-state)


so a keyword is just the shorter version of a symbol or qualified symbol


the function is call repeatedly and is supposed to look at the etc keys to figure out what to do


explaining beyond that will get very technical and it would be best to look at what the current targets do to understand


happy to help if you have specific questions but that should be the rough overview

Kira McLean19:02:32

This is very helpful! Thank you so much for the explanation. I suspect I can acheive what I’m after without needing a whole custom build target, but I see now how it’s done.. really really appreciate your guidance, thanks. And also shadow-cljs! It’s very cool.


yeah, I do think that a custom :runner-ns will probably be enough. the important bits there is just the exported init function


I vaguely remember someone doing something with devcards and shadow-cljs before but I can't find it


how you'd hook up devcards to the karma stuff I have absolutely no clue though 🙂

Kira McLean19:02:27

nice.. if I ever get it running I’ll make sure to write it down somewhere 🙂 but yeah all the pieces are here — test harness, karma-compatible test js file, etc. but they don’t work together yet.

Kira McLean19:02:28

hah.. yeah I’m on the fence about using devcards as a ui actually.. most front-end browser tests work by appending and removing the component to be tested from the dom. with the dev-card ui I’d have to somehow click around to make sure the right one is showing for the right tests.

Kira McLean19:02:53

anyway.. I’m optimistic about this 🙂 probably will pause to work on something else for a bit to give my brain a rest.. but I really would love to get it up and running! soon.

👍 3
Kira McLean19:02:03

thanks again for the pointers.


it is however not exactly documented or easy to do since they can get rather involved in low level stuff (eg. :browser


:karma is much simpler and I think already allows what you are looking for via the :runner-ns option


defaults to this one and I guess you could just create one that uses devcards instead


I'm trying to put my web-app into an app. I think looks pretty good so giving that a try. I've built and ran my app successfully, however firebase auth works a bit differently when running in apps (webview). I'm using the capacitor-firebase-auth plugin, but running into an error I haven't been able to solve yet and I think it's related to esModules stuff. The error I'm getting is: ️ TypeError: undefined is not an object (evaluating 'new q.auth.GoogleAuthProvider') Originating here: I've tried to shadow-cljs release with

:release {:compiler-options {:variable-renaming :off
                             :property-renaming :off
                             :pretty-print      true
                             :source-map        true
                             :infer-externs :auto
                             :output-feature-set :es6
                             :optimizations :simple}}
But to no avail.


Might it be there is a conflicting issue with typescript somehow? There is this comment in the readme:

1 import firebase from 'firebase/app';
    8601 export = firebase;
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
If you see the message above, please use `esModuleInterop=true` in your `tsconfig.json` file.


@bbss and how does the CLJS code looking doing this?


(ns kr.ui.firebase
  (:require ["firebase/auth"]
            ["firebase/app" :default firebase]
            ["capacitor-firebase-auth" :refer [cfaSignIn]]
            ["firebaseui" :as fbui]))

(.subscribe (cfaSignIn "") (fn [u] (js/console.log u :signed-in))) ;;offending line in my code


the library file on github does a require like this: import * as firebase from 'firebase/app';


so (cfaSignIn "") this fails?


did you verify that the firebase version you use matches EXACLTY the version capacitor-firebase-auth expects?


I did not, let me check.


firebase is notorious for changing its API constantly


so I expect that you just use an incompatible version


could be! checking.


for example in the lib there is import * as firebase from 'firebase/app'; but you have ["firebase/app" :default firebase]


those are not the same thing and only one version is correct 😛


Ugh, they're not the same?


Yeah it's a major version mismatch, the plugin has peerdep 7.x.x and I use 8.x.x




great! updating to that alpha version mentioned in the issue seems to fix it!

👍 9

Thanks for the insight @thheller


Does anybody know of an alternative to codox to auto generate documentation for a private cljs project? Codox looks great but seems like shadow w deps isn't officially supported.


(hope I'm posting in the correct place, if anyone knows a better channel to post in just lmk 🙂 )


you can just create a lein project.clj and use codox that way. as far as I know codox doesn't actually compile the code, just needs to be able to read it.


but it has been a while since I used and and only for CLJ at that