This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-27
Channels
- # architecture (6)
- # beginners (36)
- # boot (4)
- # cider (74)
- # cljsrn (5)
- # clojure (87)
- # clojure-denver (2)
- # clojure-finland (2)
- # clojure-gamedev (5)
- # clojure-italy (10)
- # clojure-nl (1)
- # clojure-uk (45)
- # clojurescript (33)
- # code-reviews (5)
- # core-async (12)
- # cursive (17)
- # datascript (2)
- # datomic (71)
- # duct (4)
- # emacs (19)
- # figwheel (1)
- # fulcro (4)
- # garden (1)
- # hoplon (18)
- # jobs (5)
- # leiningen (2)
- # off-topic (73)
- # onyx (14)
- # overtone (2)
- # portkey (32)
- # re-frame (62)
- # reagent (46)
- # shadow-cljs (76)
- # spacemacs (2)
- # sql (14)
- # tools-deps (5)
- # yada (3)
@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@thheller sorry, this one also was obvious >..< But now I better understand how it works. Thank you!
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
yes, so decided at least give this nodejs react server renderer a try, if not -- will have to rollback to this second idea
https://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157 I replicated their results basically with one exception in 3. Google never recognized dynamically generated JSON-LD metadata
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
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.
@zarkone wrote a bit of documentation here for future reference https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading
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: https://github.com/chrismurrph/default-db-format. Currently it is written mainly assuming users use Figwheel.
@cjmurphy see https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache :cache-blockers
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.

hey @thheller im trying to compile a node-script as such
//shadow-cljs.edn
{: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:
shadow.js.shim.module$react_dom$server=require("react-dom/server")
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 (RT.java:550)
clojure.lang.RT.seq (RT.java:530)
clojure.lang.APersistentMap.cons (APersistentMap.java:40)
clojure.lang.RT.conj (RT.java:670)
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.
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! 🙂
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
.
eg. shadow-cljs itself is published this way https://github.com/thheller/shadow-cljs/tree/master/packages/shadow-cljs
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. https://github.com/stevebuik/Stu
tomorrow I will deploy to clojars and log issues so anyone willing to help know where to start
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.
http://npm.anvaka.com/#/view/2d/shadow-cljs found this today. I like it very much.
@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?
@thheller in my output file (`test-ci.js`). Line looks like this: shadow.js.shim.module$react = require("react");
Ah, I was thinking it had something to do with that
Cool, will do
Thanks
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
@davidw I reported the jsonld
error here https://github.com/google/closure-compiler/issues/2909
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.(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: https://github.com/thheller/shadow-cljsjs/pull/6 Thanks for putting all that together.