Fork me on GitHub
#shadow-cljs
<
2020-03-11
>
MatD00:03:11

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 ?

cfleming01:03:02

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

pez08:03:56

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

bozhidar08:03:20

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

bozhidar08:03:40

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.

dodo04:03:18

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 https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html 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 https://github.com/mhuebert/shadow-bootstrap-example.git 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 Object.goog.globalEval (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 goog.async.run.processWorkQueue (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?

thheller09:03:36

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

thheller09:03:15

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.

thheller09:03:24

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

thheller09:03:59

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!

thheller09:03:25

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

thheller09:03:01

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

thheller09:03:36

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

thheller09:03:49

lots of manual glue code required though

👍 4
thheller17:03:09

another option is trying to pass everything through shadow-cljs but processing the jsx via babel first. https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects

thheller17:03:30

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

thheller17:03:36

also often requires manual tuning the externs

yenda09:03:43

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

yenda10:03:01

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)

thheller10:03:40

:hashbang false in the build config I think

thheller10:03:17

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

yenda10:03:38

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

thheller10:03:59

what do you need webpack for then?

thheller10:03:16

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

rickmoynihan16:03:33

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

rickmoynihan17:03:07

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

yenda16:03:04

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

thheller17:03:00

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

thheller17:03:29

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

thheller17:03:00

try limiting the ram via :jvm-opts ["-Xmx1G"]. see https://shadow-cljs.github.io/docs/UsersGuide.html#jvm-opts

thheller17:03:26

dunno how high you can go before your CI starts killing

thheller17:03:32

circleci was something arround 3G I think

yenda18:03:28

thanks again! that looks like it was the culprit