shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Aron 2021-06-22T08:21:20.183400Z

anyone actively uses react native with shadow cljs?

Aron 2021-06-22T08:38:06.183800Z

never mind, it just started working on its own. dark magic

1
Aron 2021-06-22T08:47:33.184300Z

took me more than a week from first cloning the react-native repo with shadow config 😄

thheller 2021-06-22T09:12:05.184500Z

did you not follow https://github.com/thheller/reagent-react-native?

Aron 2021-06-22T09:57:07.185300Z

it's difficult to follow something which starts from assumptions that I am ignorant about 🙂

Aron 2021-06-22T10:04:42.192400Z

That was the repo I was specifically mentioning. I tried to do those steps, and it took me over a week to get to the place where everything connects. For two days the build was working but for some reason the websocket had issues. That was the last thing, and that was the only thing that fixed itself. It requires an emulator or usb, which i haven't tested. took me a bunch of days just to be able to run the emulator, I had to disable wsl2 which contained all my working environment. Then, wherever should I get react-native binary in my PATH? I ended up using npx, so that's a diversion already, I have zero idea what you had set up. Then, for some reason, it requires create-react-class, I had to install that manually, there was no way around it. It's not part of your repo anywhere 🙂 To be clear, I am still 100% amazed that it works and it's all as promised and I am very grateful for everything.

souenzzo 2021-06-22T14:47:21.192500Z

i developed an #fulcro app targeting react native since before #shadow-cljs support react-native (~2019). I used npm-module target and things work pretty well Even things like hot reload works in some how Now I already ported most of the things to react-native target and etc I'm just sharing that things in cljs/shadow are pretty stable and you can trust them 🙂 I still think that in 2019 I had the better/fastest code-reload/dev-experience available in react-native world. And the setup to share code between native and web is WAY simpler than anything with webpack

Aron 2021-06-22T14:59:20.192700Z

yeah, react in 2017 was faster than react@next is now

2021-06-22T15:37:00.196200Z

Hi there. I’m using :module-hash-names true and when I do a release build I get the fingerprinted file. However, if I then remove the .shadow-cljs folder and do another release build I get a file which has a different fingerprint even though there have been no code or dependency changes. It appears that the munged variable names are different. Q: is this expected? I assumed that the build process would produce identical output given identical input, but maybe that’s not the case?

thheller 2021-06-22T16:53:44.196500Z

no, builds are not 100% deterministic. by deleting .shadow-cljs you are basically destroying the reproducible part 😉

2021-06-22T18:17:36.200300Z

@thheller ok, thanks for confirming. Our builds are done on CI and we are not sharing the ‘.shadow-cljs’ between build machines. We were confused as to why our fingerprints change with every build even if there are no cljs code changes.

v3ga 2021-06-22T18:24:18.202600Z

Can someone tell me what I'm missing here? I've added clojurescript/shadow-cljs to my project and when I go to my default index page I do get indication that it's picking up on shadow-cljs in the lower left corner. However as far as detecting any functions I write in core.cljs or even my cljs repl it's a no go. Not sure what else I'm missing or where I goof'd https://github.com/v3gal0g/chrysalis-xd

thheller 2021-06-22T18:40:19.203100Z

@decim "However as far as detecting any functions" what does that mean? what are you doing exactly?

v3ga 2021-06-22T18:52:16.208400Z

@thheller say I even try (js/alert “foo”) it doesn’t pick up on it. It looks like it should be reading my app.js file but it doesn’t appear so. I’m not quite sure, after tinkering for a few hours.

thheller 2021-06-22T18:53:25.208600Z

I need more information

thheller 2021-06-22T18:53:29.208800Z

WHERE do you type that?

thheller 2021-06-22T18:53:36.209Z

what commands did you run?

thheller 2021-06-22T18:56:23.209200Z

> It looks like it should be reading my app.js file but it doesn’t appear so

thheller 2021-06-22T18:56:50.209900Z

what do you mean by "It"? shadow-cljs generates the resource/public/js/app.js yes. it does not generate any HTML, so loading that file is up to you?

West 2021-06-22T19:00:00.210Z

So I tried following the instructions for using karma to test my code. Unfortunately my code is a node script and karma is a browser test suite, not designed for node. All I really want is some XML output so I can see the results in circleci. I don’t even know how to get more detailed tests, is there a verbose option? All I get is this when I run my test.

========= Running Tests =======================

Testing uniorg-util.cli-test

Testing uniorg-util.core-test

Ran 8 tests containing 31 assertions.
0 failures, 0 errors.
===============================================

thheller 2021-06-22T19:17:58.210700Z

so I assume you found :node-test?

thheller 2021-06-22T19:17:59.210900Z

> All I really want is some XML output so I can see the results in circlec

thheller 2021-06-22T19:18:11.211200Z

not sure what you mean by that

thheller 2021-06-22T19:18:38.211800Z

shadow has no built-in "xml output" for tests if thats what you are asking

West 2021-06-22T19:22:38.212400Z

I see, so I would need to configure another test runner that supports junit style xml results?

thheller 2021-06-22T19:24:27.213100Z

yeah you can configure custom runners with :node-test. in case those exist 😛

v3ga 2021-06-22T19:33:08.215200Z

Generally people throw an index.html in resources/public/ as I did. Don’t worry about it I’ll figure it out, I’m sure it’s a beginners error. If not I’m familiar with figwheel.

thheller 2021-06-22T19:39:50.216600Z

@decim and WHERE did you type (js/alert "foo")? there is a difference here to figwheel. you need either a connection from your editor or shadow-cljs cljs-repl app in addition to shadow-cljs watch app first

thheller 2021-06-22T19:40:01.216900Z

so REPL is a separate process from the watch

v3ga 2021-06-22T19:45:41.220100Z

Both using shadow-cljs repl and from emacs evaluating it in (core.cljs) with ‘npx shadow-cljs watch app’ running. Also I apologize if I came off as rude. I’m not slighting your project by any means. The issue is on my end.

thheller 2021-06-22T19:46:38.221100Z

@decim I'm trying to help you but I don't have a clue what you are doing so I'm asking what you are doing. you are only giving me small pieces of information that don't really tell me what you are doing.

grav 2021-06-22T20:01:32.223Z

Hey! Whenever I make a change in my cljs.user, and Shadow-cljs hot-reloads it, and I then try executing something in the repl, I get the following exception:

------ REPL Error while processing ---------------------------------------------
foo
no source by provide: cljs.user
{:provide cljs.user}
ExceptionInfo: no source by provide: cljs.user
	shadow.build.data/get-source-id-by-provide (data.clj:186)
.....
Only seems to be the case for cljs.user

thheller 2021-06-22T20:06:21.223600Z

@grav which version are you on? that should have been fixed for a while now?

grav 2021-06-22T20:08:10.223800Z

@thheller Latest: 2.14.5

grav 2021-06-22T20:08:36.224200Z

Here's more info:

[2021-06-22 22:07:23.472 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "foo", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form foo, :source "foo", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:501)
        shadow.cljs.repl/process-read-result (repl.clj:475)
        shadow.cljs.repl/process-input (repl.clj:659)
        shadow.cljs.repl/process-input (repl.clj:637)

grav 2021-06-22T20:10:30.224900Z

I'm using :deps {:aliases [:cljs]}, and then I have :paths ["src" "dev"] in my deps.edn, and cljs.user is in dev/cljs/user.cljs

thheller 2021-06-22T20:11:09.225200Z

would help if you can setup a reproducible repo

grav 2021-06-22T20:11:52.226Z

Alright - I'll see if I can do that :thumbsup: Is there a work-around for now, can I eg avoid having shadow hot-reload cljs.user

thheller 2021-06-22T20:13:22.226500Z

you can have (ns cljs.user {:dev/once true} ...) meta to only load it once. not sure that fixes anything

grav 2021-06-22T20:16:46.227200Z

Doesn't seem to unfortunately.

West 2021-06-22T20:17:28.227300Z

So I managed to find https://github.com/lambdaisland/kaocha-junit-xml. I’m currently trying to see if I can get https://github.com/lambdaisland/kaocha-cljs2 working.

grav 2021-06-22T20:23:04.228700Z

Tried to use :repl-init-ns with another namespace - same problem with that namespace. Anyway, I'll create a repro.

grav 2021-06-22T20:46:40.229100Z

@thheller There you go: https://github.com/grav/shadow-cljs-user-issue 🙂 Will also create an issue

grav 2021-06-22T20:50:12.229600Z

Created issue here: https://github.com/thheller/shadow-cljs/issues/905 Thanks for looking into it 🙂

v3ga 2021-06-22T21:19:50.232500Z

Ha I got it! In shadow-cljs.edn…. :modules {:app … changed that to main and pulled main.js in index.html and now we have lift off.

2🎉