Fork me on GitHub

Hi! I'm new to shadlow-cljs and I'm searching for a better testing workflow. I'm targetting a nodejs project and right now I have a :node-test target working, which is great, but the console output is a bit plain and I'm looking for editor integration to spot any failure more easily and focus on failing tests directly in an editor. I tried VSCode Calva, but the tests commands dont work with shadow-cljs yet. Is it better with Cursive or Cider ?


I’m not sure about Cider, but sadly Cursive’s test integration doesn’t work with CLJS yet.


Calva uses CIDER's tech for testing, so I doubt it will look any better there... Wdys@U051BLM8F?


Same with CIDER - the test middleware currently supports only Clojure.


Handling ClojureScript is not rocket science and would mostly involving piping some ClojureScript evals to the eval middleware, as obviously we can’t run ClojureScript directly, as we do with Clojure.


Is there a way to set repository infomation, like the maven using settings.xml or lein using ~/.lein/profiles.clj ?

Mikko Harju07:03:06

I'm using as the basis for self-hosting a compiler in an application. It works well on development, but if I try to do release with it, it complains about not having access to goog -namespace. It seems to be loading the bootstrap stuff from the output folder I have assigned but the evaluation itself fails. I'm using re-plumb for now, is it something to do with that? Should I just stop using it and switch to the built-in one mentioned in the blog post instead?

Mikko Harju07:03:33

If I test the example and do a release build, it complains about the same:

base.js:5319 Uncaught ReferenceError: goog is not defined
    at eval (/js/bootstrap/js/75b50edc.cells.lib.js:1)
    at eval (<anonymous>)
    at (base.js:251)
    at Object.shadow.cljs.bootstrap.browser.script_eval (base.js:5513)
    at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (base.js:5516)
    at base.js:5526
    at (base.js:5326)

Mikko Harju07:03:18

On lein & figwheel the release build with simple optimizations worked. Do I need to deploy the development version as is in order for this to work with shadow-cljs?


@U32ST9GR5 you need to set :compiler-options {:optimizations :simple} for your "host" build. :advanced (the default) is not supported.


oh and you might need to disable :compiler-options {:output-wrapper false} too

Mikko Harju09:03:59

@U05224H0W the optimizations: simple was already in place. I'll add the output-wrapper and see what happens!

Mikko Harju09:03:34

output-wrapper: false solved the issue for me. Thanks again for your fast response. So, I'm guessing the output-wrapper is a function that basically hides the goog from being globally available and removing that fixes it.


it hides all globals yes, goog is just the first that is accessed


cljs would be the next and so on

👍 4
Jakub Holý (HolyJak)09:03:52

Hello! Any tips for incrementally migrating a React app to ClojureScript? I.e. for a while I am going to have both cljs Fulcro components/files and React .jsx files in the same project, using each other. How do I compile this mess? The React files of course use .jsx and possibly require Babel. Thank you!


probably via :npm-module and sticking with webpack for a while


oh no wait ... that way fulcro can't use your react components


hmm then it is probably best to keep everything separate and assign things to a global that is shared


lots of manual glue code required though

👍 4

another option is trying to pass everything through shadow-cljs but processing the jsx via babel first.


but if you use any webpack specific stuff that won't be very reliable


also often requires manual tuning the externs


Not sure about fulcro but with reagent that would be easy you make a react-native lib with your react app and use r/adapt-react-class to use the react components


Is there a way to not append #!/usr/bin/env node at the beginning of a node-script target, besides removing it afterward with sed? (in order to compile in the nodejs deps with webpack)


:hashbang false in the build config I think


if you intend to consume from webpack you should likely be using :node-library though


but then I need to export a symbol? I just want to run node myfile.js


what do you need webpack for then?


ah you want to bundle the deps so its self-contained?


Does anyone use shadow-cljs with devcards or an equivalent, e.g. storybook?


Ahh thanks — I new I’d seen something else!


is it possible that shadows silently fails to create the output file but still says done? I see the following in circle ci:

[:api] Compiling ...
Done in 37.24s.
and then from time to time a task fails saying the file doesn't exist, which I can confirm by running a ls after shadow, the file isn't there


@yenda Done isn't from shadow-cljs it is from the CI


in the pass this has happened when the CI system kills the shadow-cljs process because it was consuming too much ram


try limiting the ram via :jvm-opts ["-Xmx1G"]. see


dunno how high you can go before your CI starts killing


circleci was something arround 3G I think


thanks again! that looks like it was the culprit