Fork me on GitHub

@thheller I use a tool with cljs-shadow that requires an entry in [:devtools :preloads]. This tool reads from its own .edn configuration file. The same tool works with Figwheel and the instruction was to (reload-config) after making changes to the configuration file. Is there an equivalent command for cljs-shadow? What worked for me was to rm -rf the builds directory.


hi, I have another dumb question about cljc! so, I've defined a few lines in .cljc file:

#?(:node-script (.log js/console (str "HAHAHAHA.1")))
#?(:browser (.log js/console (str "HAHAHAHA.2")))
#?(:cljs (.log js/console (str "HAHAHAHA.3")))
and I also have this in build conf:
:reader-features #{:node-script}
:target :node-script
but I get only :cljs branch compiled, for some reason. Tried to use :node instead, same result


@cjmurphy which tool is that?


@zarkone :compiler-options {:reader-features #{:node-script}}


@thheller sorry, this one also was obvious >..< But now I better understand how it works. Thank you!


I'll probably add a section about it in the docs. It is a useful feature after all.


yes, it is, definitely! Currently porting our SPA app to SSR, quite tough task, but I think it would be impossible at all without complete rewriting without this conditional features


yeah thats what I used it for too. although I abandoned the SSR idea half way through. couldn't live with having to do JS on the server 😉


yes, but I just don't know any other solution in my case: we have SPA app and now "it turns out" that we need SEO to actually be crawler-friendly and etc


either completely different codebase, doing html version for crawlers or something like this.


SEO with just plain SPA can work but it seems to take google longer to index this and doesn't work at if you send out too many requests and such


+ bing and others definitely don't index SPAs properly


so yeah HTML is probably the safest option


yes, so decided at least give this nodejs react server renderer a try, if not -- will have to rollback to this second idea

thheller08:04:11 I replicated their results basically with one exception in 3. Google never recognized dynamically generated JSON-LD metadata


but definitely try the node server renderer and blog about your experience


maybe you have more patience than I did 😉


haha) you suggest to add yet another tutorial article about server-side rendering to feed trolls? 🙂 ok, sounds nice -- at least, I haven't seen the one with shadow-cljs, AFAIR


hehe 😉


What is the correct way specify shadow-cljs version in package.json and shadow-cljs.edn? Should they match 100% time or is it redundant to have it in shadow-cljs.edn


not required in shadow-cljs.edn at all. it will pick whatever version is installed by npm so only package.json matters.


don't need to specify a clojurescript or clojure version either.


Looks great in my opinion! All the problems I've faced so far were touched. Thank you! :)


@thheller Its a tool I use with Fulcro that catches anytime the state becomes de-normalized: Currently it is written mainly assuming users use Figwheel.


you'll probably need to add the default-db-format.prefs since that does a side-effecting read of the config file


deleting all the cache is kind of a nuclear option and not really required. since its only about that one single thing.

simple_smile 4

hey @thheller im trying to compile a node-script as such

{:builds {...
   :target :node-script}}

$ shadow-cljs release <script-id>
and based on the documentation it's supposed to output some single-file stand-alone script. But when I take it out of the directory it was built and put it inside a new dir, it won't run. I've tried to debug the problem and it seems that use the nodejs require as such:
So I then figured that maybe I can use the :js-options :shadow and I did but now I'm stuck because while it works on the watch mode it will fail on release. I'm running it likeso:
$ shadow-cljs release <script-id> --debug

IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
	clojure.lang.RT.seqFrom (
	clojure.lang.RT.seq (
	clojure.lang.APersistentMap.cons (
	clojure.lang.RT.conj (
	clojure.core/conj--5112 (core.clj:85)
	clojure.core/merge/fn--5679 (core.clj:3041)
	clojure.core/reduce1 (core.clj:936)
	clojure.core/reduce1 (core.clj:926)
And I have no idea how to debug from this 😞


@j it outputs a single file yes. it however still requires the node_modules files since node will load these. so if you move the file you need to move it together with the package.json and install the deps in a new location.


it is not currently supported to bundle all deps since that would significantly reduce the number of packages you'd be able to use (ie. nothing with native deps)


:js-provider :shadow can work in theory but I never tested it in combination with :node-script


"stand-alone" in the docs mean that shadow-cljs is not required after the file is compiled. it does not mean that node_modules will be bundled.


I can take a look at making :js-provider :shadow work with :node-script later but as I said this severly limits the number of packages you'll be able to use.


I will clarify this in the docs.


Thanks for the quick reply, and it seems that the quick solution is just to include a package.json. Either way, great work on this tool! 🙂


yep that is best


I typically create an extra :output-to "out/foo.js" directory with a dedicated out/package.json file that only contains stuff actually required to run the script. eg. no devDependencies.


am I right in thinking using the path to a jsfile within an npm package in the require e.g.

(ns foo.core
  (:require ["jsonld/dist/jsonld.js" :as jsonld]))
and using :js-options :resolve to redirect the require e.g.
:js-options {:resolve {"jsonld" {:target :npm
                                  :require "jsonld/dist/jsonld.js"}}}
(ns foo.core
  (:require ["jsonld" :as jsonld]))
should be equivalent?


hi everyone. I’ve made significant progress on Stu this week. check out the latest.


tomorrow I will deploy to clojars and log issues so anyone willing to help know where to start


I’d appreciate any feedback


love the pre-closure toggle. the switch for compressed however is a bit useless since everything should always be zipped the the other number is a bit irrelevant. unlikely you gzip one release but not the other.


still not a super fan of the tree-map display. hard to make out any actually useful info.


definitely need to trim some deps for shadow-cljs 😉


@thheller Good to know. Are you able to state the questions that you are trying to answer? That will enable me to know what new features you and others would find valuable


I followed the guides for :target :karma, and the shadow-cljs build goes through fine, but when doing karma start I’m getting a reference error require is not defined


Running on shadow-cljs 2.3.10 and configs look like this:


@colindresj require is not defined where? any chance your code has a js/require call somewhere?


@davidw yes that is equivalent when using :target :browser


@thheller in my output file (`test-ci.js`). Line looks like this: shadow.js.shim.module$react = require("react");


oh the extra resolve toggled something off


js-options isn't getting merged it is replaced


Ah, I was thinking it had something to do with that


oops. you can temp fix it by adding :js-options {:js-provider :shadow :resolve ...}


will fix that in next release


Cool, will do


As an aside, I thought shadow was the default provider @thheller


Is it target specific?


Actually that makes sense — for node is probably require, etc


yeah :shadow is only the default for the :browser, otherwise :require


Hi, I have a dependency that requires the jquery cljsjs package. So I added th jquery.cljs file in the cljsjs package like this:

(ns cljsjs.jquery
  (:require ["jquery" :as jquery]
                 ["$" :as jq]))

(js/goog.object.set jquery "$" jq)
(js/goog.exportSymbol "jquery" jquery)
The first error: The required namespace "cljsjs.jquery" is not available, it was required by "re_pressed/impl.cljs". is gone, but now it complains about $: `The required JS dependency "$" is not available, it was required by "cljsjs/jquery.cljs". Any idea how to reference that? My code above does not work.


Thanks to @gadfly361 I have this working now:

🍻 4

(ns cljsjs.jquery
  (:require ["jquery" :as jquery]))

(js/goog.exportSymbol "jQuery" jquery)


@thheller good to know about the reported issue. We ran into that and are working around it by using the jsonld/dist/jsonld.js require redirect but that wasn't working with our :target :karma build where we got require is not defined errors running the tests. It worked when I put the path in the require directly which seemed strange, hence the question. So it looks like we were running into the same issue as @colindresj


@davidw yeah thats my bad. should be fixed in the 2.3.11 release I just pushed. or just add :js-provider :shadow to your :js-options.


@sveri $ is only the variable, it is not an npm package. you can just add the additional (js/goog.exportSymbol "$" jquery) if you like


@thheller I got it working without the $ line. I already added a PR: Thanks for putting all that together.


ah excellent. thx.


@thheller thanks for the instant release, I just included the updated version and it works, awesome. Do you have a automatic build set up?


not really. but its just lein deploy clojars so pretty quick to do.