shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
2020-12-17T06:25:26.482800Z

Hello. I am using material UI, when use project.clj from luminus template, everything works fine. But I switch to shdow-cljs cli, some component style is not working well. This branch is using lein: https://github.com/kimim/vorstellung and this branch uses shadow-cljs https://github.com/kimim/vorstellung/tree/shadow . When click Date Picker or DataGrid, the menu works wrongly.

Shako Farhad 2020-12-17T10:01:30.485700Z

Hey guys. I have setup a shadow-cljs project with deps.edn. When I run the

clj -A:shadow-cljs-dev watch app
command I get a server up and running and things are great. But after I quit it with "ctrl + z" the server lingers forever. I can go to localhost:8700 and still see my app running there. If I restart the watch app then it will says that my build is stale and was not produced by the current watcher. Only workaround is to change the port. Anyone know how to fix this? Reboot doesn't help either. So something is cached somewhere? My deps.edn alias:
:shadow-cljs-dev
  {:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
                re-frame/re-frame {:mvn/version "1.1.2"}
                binaryage/devtools {:mvn/version "1.0.2"}
                re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305 
                                                                     re-frame/re-frame]}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}
I have manually killed all the processes, rebooted the pc etc. But when I go to localhost:8700, the app is still being served there. And in the corner it says "shadow-cljs reconnecting...". If I try to start a new watch on that same port it will say that it is stale.

thheller 2020-12-17T10:01:47.486100Z

@kimi.im what do you mean by "shadow-cljs cli"? you should still start the server parts using lein?

2020-12-18T09:28:53.022800Z

I think there are many problems. Firstly, material UI implement js loaded css, some element will overwrite the global css. Secondly, I do not know why use lein shadow there is no problem, but use shadow-cljs, there are problems. Anyway, I plan not use Material UI now.

thheller 2020-12-18T10:16:29.023Z

I can't do much without a reproducible repo. too many unknown for me. if you set one up I'll take a look and maybe fix it.

2020-12-18T11:58:11.023200Z

Hello @thheller, I put two projects in github: https://github.com/kimim/shadow-mui Could you help to have a look? Thanks.

thheller 2020-12-18T12:16:47.023500Z

https://github.com/kimim/shadow-mui/tree/master/shadow-cljs there is no shadow-cljs.edn?

2020-12-18T12:18:49.023700Z

sorry, it was ignored in .gitignore. Now I add it back.

2020-12-18T12:22:58.023900Z

and also package.json is ignored. I add it back also.

thheller 2020-12-18T12:27:12.024100Z

$ clj -M:run
Syntax error (FileNotFoundException) compiling at (vorstellung/middleware.clj:1:1).
Could not locate vorstellung/env__init.class, vorstellung/env.clj or vorstellung/env.cljc on classpath.

Full report at:
/tmp/clojure-14799446093176938932.edn

thheller 2020-12-18T12:27:34.024300Z

in the shadow-cljs folder

2020-12-18T12:27:47.024500Z

sorry, please pull again, one config file is missing.

thheller 2020-12-18T12:36:16.024700Z

one mistake I see is the deps.edn using :resource-paths. that is not a thing in deps.edn

2020-12-18T12:38:27.024900Z

Thanks. If removed, there is the same problem. Iโ€™m just trying every possible solutions..

thheller 2020-12-18T12:40:33.025100Z

other than that the only problem I see is that there is a justify-content: center; css rule on one element which causes everything to center

thheller 2020-12-18T12:40:41.025300Z

don't know why its there but thats the cause

thheller 2020-12-18T12:40:54.025500Z

on .MuiButtonBase-root

thheller 2020-12-18T12:41:30.025700Z

so far it looks like everything is working as intended?

2020-12-18T12:42:26.025900Z

If use the shadow-cljs branch, when you click the red menu item, the menu will be in disorder

thheller 2020-12-18T12:42:50.026100Z

that is what I mean ...

thheller 2020-12-18T12:43:03.026300Z

"disorder" isn't quite right. it is "centered"

2020-12-18T12:43:30.026500Z

Yes, centered and shrinked a little

2020-12-18T12:44:42.026700Z

Three button over the table โ€œload, send and exportโ€ is also turn to white. It is blue in lein-shadow branch.

2020-12-18T12:46:07.026900Z

If comment the table in src/cljs/vortellung/app/table.cljs: #_[people] everything turns OK

2020-12-18T12:46:53.027100Z

or this part:

2020-12-18T12:47:18.027300Z

clojure #_[:> m/TableContainer {:style {:height "80vh", :width "auto"}} [:> dg/DataGrid {:rows rows :columns cols :checkboxSelection true :autoPageSize true :exportAllData true}]]```

thheller 2020-12-18T12:47:53.027500Z

the lein run doesn't work at all for me

thheller 2020-12-18T12:48:06.027700Z

<http://localhost:3030/js/home.js> I get some swagger stuff

thheller 2020-12-18T12:48:55.027900Z

ah nevermind. I guess because the js is missing

2020-12-18T12:50:36.028100Z

In lein-shadow branch, if lein run not work, you can use clj -M:run also. and use lein shadow watch home app

thheller 2020-12-18T12:51:38.028400Z

why are home and app two builds?

2020-12-18T12:52:36.029300Z

home build contains some authentification stuffs. But I removed in these two sample.

thheller 2020-12-18T12:55:58.031200Z

I'm sorry but I really can't tell what is going on in this template at all

thheller 2020-12-18T12:56:05.031400Z

waaaaaaaaaaaaaaay to much other stuff I can't look at

thheller 2020-12-18T12:56:39.031600Z

the CLJS parts look fine but the CLJ server parts I can't figure out

2020-12-18T12:59:07.032Z

But If CLJ server is running with clj -M:run it should be same as shadow-cljs branch..

2020-12-18T13:01:06.032200Z

So far as I know, the only different is the way to run shadow-cljs, with lein shadow or with shadow-cljs .

2020-12-18T13:09:05.034100Z

I try to reproduce the issue after remove the backend and some unrelated codes.

2020-12-23T03:27:14.100600Z

Hello @thheller, I simplify the code in the same repo, could you help to have a look? Thanks: https://github.com/kimim/shadow-mui

thheller 2020-12-23T10:03:14.102600Z

can you get rid of all the server-side code and just use :dev-http static webserver? the server parts are the confusing bits for me

2020-12-23T11:25:56.107200Z

I donโ€™t how to create client only SPA. Thank you for your reminds. I will try :dev-http

thheller 2020-12-23T11:26:47.107400Z

you just take out everything that talks to the server

2020-12-23T11:51:34.107600Z

Server parts are removed now.

thheller 2020-12-23T12:59:47.107900Z

so I upgraded the shadow-cljs version in lein-shadow to 2.11.10 so both variants use the same version

thheller 2020-12-23T12:59:54.108100Z

and they look exactly the same then

thheller 2020-12-23T13:02:57.108300Z

you can add :js-options {:entry-keys ["browser" "main"]} to your build config which appears to make it work

๐Ÿ‘ 1
thheller 2020-12-23T13:03:25.108500Z

why I can't quite tell. looks like something in material-ui behaves differently when using "module" as well

2020-12-23T13:04:45.108700Z

Thank you. I just realized that these two branches use different version of shadow-cljs, sorry for this.

2020-12-23T13:07:55.110400Z

:js-options {:entry-keys ["browser" "main"]} solve this issue. Thatโ€™s great!

thheller 2020-12-23T13:10:53.112100Z

you should maybe consider removing this and just requiring all the esm code directly

thheller 2020-12-23T13:11:08.112500Z

otherwise you end up with a weird mix of commonjs and esm

thheller 2020-12-23T13:11:24.112700Z

material ui is one of those packages that contains 15 different variants on the code in one package

thheller 2020-12-23T13:11:39.112900Z

basically you just add an esm path to all requires

thheller 2020-12-23T13:12:32.113100Z

so isntead of ["@material-ui/icons/Build" :default Build] you use ["@material-ui/icons/esm/Build" :default Build]

2020-12-23T13:13:16.113300Z

OK, I will try this solution. Thanks very much.

2020-12-23T13:33:34.113500Z

this way is not working:ย `["@material-ui/icons/Build" :default Build]`ย toย `["@material-ui/icons/esm/Build" :default Build]`

thheller 2020-12-23T13:39:11.113700Z

sorry no time to look into this today. guess the old way is fine then.

2020-12-23T13:40:05.113900Z

Yes. :js-options {:entry-keys ["browser" "main"]} this way is fine now. Thank you for your time. It helps a lot.

thheller 2020-12-17T10:02:20.487Z

@shakof91 ctrl+z sends the process to the background and keeps it running, ctrl+c stops it.

2020-12-17T10:02:48.487800Z

no matter server is started by Leon or clj, the result is the same. Iโ€™ve compared with both.

2020-12-17T10:03:25.488900Z

I guess there is some thing I did wrong with shadow-cljs. The lein integrated way works fine.

thheller 2020-12-17T10:03:30.489100Z

do you get a 404 on some css or so?

2020-12-17T10:04:16.489600Z

css is correctly loaded.

2020-12-17T10:06:13.490100Z

Type โ€œfgโ€ will get it back

Shako Farhad 2020-12-17T10:10:22.490300Z

It has the same behaviour. The page is stuck at "shadow-cljs - reconnecting ..." instead of showing a blank page after I run "ctrl + c". This is what I see in the console. In addition a lot of sourcemap warning spam comes too.

shadow.cljs.devtools.client.websocket.js:sourcemap:4 WebSocket connection to '<ws://localhost:9630/api/remote-relay?server-token=db38e25d-695e-4f5b-ac50-6e8c80783d8a>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
shadow$cljs$devtools$client$websocket$start @ shadow.cljs.devtools.client.websocket.js:sourcemap:4
eval @ shadow.cljs.devtools.client.shared.js:sourcemap:467
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shadow.cljs.devtools.client.shared.js:sourcemap:929
eval @ shadow.cljs.devtools.client.browser.js:sourcemap:952
goog.globalEval @ app.js:577
env.evalLoad @ app.js:1670
(anonymous) @ app.js:1945
shadow.cljs.devtools.client.shared.js:sourcemap:651 shadow-cljs - remote-error Eventย {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2,ย โ€ฆ}
This wouldn't be a problem if I could run the watch command again and just be able to continue developement from the same port again, but I instead get this message: "Shadow-cljs - stale output! Your loaded js was not produced by the running shadow-cjs instance. Is the watch running?" Even if I try to delete the .shadow-cljs folder, the .cpcache folder and remove the app.js files, it will still say this as long as I use the same port.

thheller 2020-12-17T10:42:07.490500Z

I don't understand your issue. what do you expect?

thheller 2020-12-17T10:42:36.490700Z

the server started by lein is serving the content. shadow-cljs just produces the javascript and it needs to be running for that JS to connect back

thheller 2020-12-17T10:42:46.490900Z

don't start 2 shadow-cljs instances for the project or you will get a mess

Shako Farhad 2020-12-17T10:44:33.491200Z

My expectation is that I can stop the watch and restart it later. So maybe I am not understanding how to start and stop it. I thought it was just to stop it with ctrl + c and run it again with "clj -A:shadow-cljs-dev watch app" again.

Shako Farhad 2020-12-17T10:46:18.491400Z

I am also expecting that the websocket will stop when I run ctrl + c so that the browser doesnt show my app anymore. I have disabled caching in the browser as well so I would expect that the app wouldn't linger when I go to localhost:8700 after I have stopped it. :x

thheller 2020-12-17T10:47:18.491600Z

what commands do you run exactly? I mean to me it sounds like you just have 2 instances running

thheller 2020-12-17T10:48:00.491800Z

first check there is actually only one instance running. you can check how many instances via jps or so

Shako Farhad 2020-12-17T10:48:18.492Z

{
  "name": "bec-core",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "watch-app": "clj -A:shadow-cljs-dev watch app",
    "release-app": "clj -A:shadow-cljs-prod release app",
    "cljs-repl": "clj -A:shadow-cljs-dev cljs-repl app"
  },
  "dependencies": {
    "react": "16.13.0",
    "react-dom": "16.13.0"
  }
}
That is my package.json and I run
npm run watch-app
It builds etc just fine and then I press "ctrl + c"

thheller 2020-12-17T10:49:28.492200Z

and what do you get?

thheller 2020-12-17T10:49:37.492400Z

there should be a "server shutdown" message

Shako Farhad 2020-12-17T10:50:09.492600Z

shako$ npm run watch-app

&gt; bec-core@0.0.1 watch-app
&gt; clj -A:shadow-cljs-dev watch app

shadow-cljs - HTTP server available at <http://localhost:8710>
shadow-cljs - server version: 2.11.8 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 52471
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (268 files, 0 compiled, 0 warnings, 5.22s)
Worker shutdown.

thheller 2020-12-17T10:50:36.492800Z

thats just the worker not the server

thheller 2020-12-17T10:50:57.493Z

try jps to see if there is a running java process

Shako Farhad 2020-12-17T10:51:37.493200Z

shako$ jps
7582 Jps
shako$ jps -l
7600 jdk.jcmd/sun.tools.jps.Jps
I haven't used jps before. I am not exactly sure what to expect. :x

Shako Farhad 2020-12-17T10:53:50.493400Z

I ran the jps command in the windows terminal instead of the WSL2 ubuntu terminal:

C:&gt;jps
12576 RemoteMavenServer36
18528 Jps
17028 RemoteMavenServer36
3204 RemoteMavenServer36
5796 RemoteMavenServer36
6472 RemoteMavenServer36
12908 RemoteMavenServer36
14380 RemoteMavenServer36
12592 RemoteMavenServer36
16336
3408 RemoteMavenServer36
8592 RemoteMavenServer36
11316 RemoteMavenServer36
10552 RemoteMavenServer36
3672 RemoteMavenServer36
13212 RemoteMavenServer36

Shako Farhad 2020-12-17T10:54:05.493600Z

THis is the culprit huh? ๐Ÿ˜„

Shako Farhad 2020-12-17T10:54:47.493800Z

C:&gt;jps -l
12576 org.jetbrains.idea.maven.server.RemoteMavenServer36
17028 org.jetbrains.idea.maven.server.RemoteMavenServer36
3204 org.jetbrains.idea.maven.server.RemoteMavenServer36
5796 org.jetbrains.idea.maven.server.RemoteMavenServer36
6472 org.jetbrains.idea.maven.server.RemoteMavenServer36
12908 org.jetbrains.idea.maven.server.RemoteMavenServer36
14380 org.jetbrains.idea.maven.server.RemoteMavenServer36
12592 org.jetbrains.idea.maven.server.RemoteMavenServer36
16336
3408 org.jetbrains.idea.maven.server.RemoteMavenServer36
8592 org.jetbrains.idea.maven.server.RemoteMavenServer36
11316 org.jetbrains.idea.maven.server.RemoteMavenServer36
22100 jdk.jcmd/sun.tools.jps.Jps
10552 org.jetbrains.idea.maven.server.RemoteMavenServer36
3672 org.jetbrains.idea.maven.server.RemoteMavenServer36
13212 org.jetbrains.idea.maven.server.RemoteMavenServer36

Shako Farhad 2020-12-17T10:55:22.494Z

Looks like intellij processes, right?

thheller 2020-12-17T11:02:14.494200Z

might be the 16336?

thheller 2020-12-17T11:02:23.494400Z

check with regular ps or so

thheller 2020-12-17T11:03:18.494600Z

you are using npm and clj and either of those may be causing the server to linger. I can't say. I can only help with actual running shadow-cljs commands

thheller 2020-12-17T11:04:08.494800Z

any reason you are not using the shadow-cljs command?

Shako Farhad 2020-12-17T11:09:57.495Z

We are trying to use deps.edn for the dependancy management and the recommended way was to use the clj -A:alias watch app command to run shadow-cljs through the shadow-cljs.devtools.cli.

thheller 2020-12-17T11:10:21.495200Z

no that isn't recommended anywhere

thheller 2020-12-17T11:10:54.495400Z

you can still use deps.edn to manage dependencies. that is totally fine.

Shako Farhad 2020-12-17T11:11:37.495600Z

https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn

Running with clj directly.

{:paths [...]
 :deps {...}
 :aliases
 {:shadow-cljs
  {:extra-deps {thheller/shadow-cljs {:mvn/version &lt;latest&gt;}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
clj -A:shadow-cljs watch app
Is what I followed in the documentation. Perhaps I am just too noob to know how to properly setup and run with deps.edn :s

thheller 2020-12-17T11:13:58.495900Z

that is meant as an example that you CAN run with clj directly. doesn't mean you should.

thheller 2020-12-17T11:14:18.496100Z

it is completely fine to do this. I just can't help you with debugging issues then ๐Ÿ˜›

thheller 2020-12-17T11:14:32.496300Z

you should run the regular shadow-cljs watch app and so on

thheller 2020-12-17T11:14:54.496500Z

I guess I should clarify that in the docs

Shako Farhad 2020-12-17T11:14:57.496700Z

How can I setup dev dependancies and prod dependancies when using deps.edn and shadow-cljs installed globally? ๐Ÿ˜ฎ

thheller 2020-12-17T11:16:37.496900Z

you don't have to in CLJS

thheller 2020-12-17T11:16:54.497100Z

just keep everything on the classpath all the time

Shako Farhad 2020-12-17T12:47:02.497300Z

I am sorry I am really noob at this. What exactly do you mean? Just ignore deps.edn and let shadow-cljs handle the deps? This is how I have set it up: deps.edn

{:paths ["src" "resources" "target"]

 :deps
 {org.clojure/clojure {:mvn/version "1.10.1"}}

 :aliases
 {:cljs
  {:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
                re-frame/re-frame {:mvn/version "1.1.2"}
                binaryage/devtools {:mvn/version "1.0.2"}
                re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305
                                                                     re-frame/re-frame]}}}}}
shadow-cljs.edn
{:deps {:aliases [:cljs]}

 :builds
 {:app
  {:target :browser
   :output-dir "resources/public/js"
   :modules {:app {:entries [bec-core.cljs.core]}}

   :js-options {:js-package-dirs ["node_modules"]}

   :compiler-options {:infer-externs :auto}

   :dev {:closure-defines {goog.DEBUG true}}
   :devtools
   {:before-load bec-core.cljs.core/stop
    :after-load bec-core.cljs.core/start
    :http-root    "resources/public"
    :http-port    8711
    :preloads     [devtools.preload
                   re-frisk.preload]}}}}
Running it like this:
$ npx shadow-cljs watch app
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at <http://localhost:8711>
shadow-cljs - server version: 2.11.8 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 60273
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (270 files, 59 compiled, 0 warnings, 24.61s)
^C
$ Worker shutdown.
npx shadow-cljs stop app
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - server not running
I don't know how to exlude refrisk and dev-tools dependancies from the release version of the app. Also even when I run shadow-cljs through npx it still has the same issue. I can't stop the server with ctrl + c. The browser still shows the old app running and a new watch on the same port won't update anymore. It will just ocmplain about a stale build.. ๐Ÿ˜•

Shako Farhad 2020-12-17T13:05:09.497500Z

just type fg in the terminal? THis waht I tried:

:/mnt/c/bec-core$ fg
-bash: fg: current: no such job
:/mnt/c/bec-core$ npx shadow-cljs fg
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"

Invalid action "fg"

thheller 2020-12-17T13:11:19.497700Z

you don't need to exclude dev stuff from release. shadow-cljs only includes what you actually require in your code in the build

thheller 2020-12-17T13:11:34.497900Z

so it absolutely does not matter if devtools and refrisk are on the classpath for release builds

Shako Farhad 2020-12-17T13:11:58.498100Z

Ah I understand! Wow that is smart! ๐Ÿ˜„

thheller 2020-12-17T13:12:15.498300Z

you also don't need these

:js-options {:js-package-dirs ["node_modules"]}

   :compiler-options {:infer-externs :auto}

   :dev {:closure-defines {goog.DEBUG true}}

thheller 2020-12-17T13:12:19.498500Z

those are already the defaults

thheller 2020-12-17T13:12:53.498700Z

I don't have a clue why you can't stop the server via ctrl+c. which OS is this?

thheller 2020-12-17T13:13:06.498900Z

which clojure version?

thheller 2020-12-17T13:13:38.499100Z

fg only works after you ctrl+z a process. it is not a shadow-cljs command, its a linux thing

Shako Farhad 2020-12-17T13:14:02.499300Z

I am running on windows 10 in WSL2 ubuntu terminal.

$ clj --help
Version: 1.10.1.561

thheller 2020-12-17T13:15:57.499500Z

so if you just run shadow-cljs server and ctrl+c that the process still lingers?

Shako Farhad 2020-12-17T13:21:15.499700Z

$ npx shadow-cljs server
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at <http://localhost:8712>
shadow-cljs - server version: 2.11.8 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 50490
^C
THe page at http://localhost:9630 dissappears when I reload it. So it works as expected when I ctrl + c. But http://localhost:8712 is still there. "Shadow-cljs - reconnecting..." And when I start the server the message just becomes "Shadow-cljs stale build etc."

Shako Farhad 2020-12-17T13:22:48.499900Z

Windows terminal result:

C:\bec-core&gt;jps -l
10088 jdk.jcmd/sun.tools.jps.Jps
1980
Ubuntu terminal result:
bec-core$ jps -l
9068 jdk.jcmd/sun.tools.jps.Jps

thheller 2020-12-17T13:23:42Z

if you start it in wsl2 then only that matters. the windows side doesn't matter at all.

thheller 2020-12-17T13:23:49.000200Z

can't mix them

Shako Farhad 2020-12-17T13:24:27.000400Z

Alright. All commands are run in WSL2. I don't have clojure installed on windows 10, only in WSL2.

thheller 2020-12-17T13:24:40.000600Z

get your system into a state where <http://localhost:8712> serves nothing

Shako Farhad 2020-12-17T13:24:59.000800Z

Yes, I am trying the best I can. I even rebooted the machine and it still is there :s

thheller 2020-12-17T13:25:09.001Z

ok that is definitely not shadow-cljs then

thheller 2020-12-17T13:25:40.001200Z

maybe you have some other server running there or some cache stuff I don't know

Shako Farhad 2020-12-17T13:26:22.001400Z

My app starts a service worker to register the app. Is it perhaps that which is causing it to not let go?

Shako Farhad 2020-12-17T13:30:44.001600Z

Yep. Now it behaves as expected! I removed this piece of the code:

(try
    (-&gt; (. js/navigator.serviceWorker (register "/service-worker.js"))
      (.then (fn [] (js/console.log "service worker registered"))))

    (catch js/Object err (js/console.error "Failed to register service worker" err)))
And now the browser is properly letting go. So it is probably a chrome issue. I wonder how to fix it...

thheller 2020-12-17T13:32:06.001800Z

ah you used a service worker ... yeah you shouldn't cache the output of a watch build ever. just disable that in the worker.

Shako Farhad 2020-12-17T13:35:06.002Z

Is it possible to output the release version to a different directory than the watch build output? I could then set the service worker to cache the release version only? Or perhaps the right way to do this is to register the service worker in release mode only, using the goog.DEBUG to toggle the registering of the service worker... Not sure what is best to do ๐Ÿ˜ฎ

Shako Farhad 2020-12-17T13:46:57.002200Z

One solution for now is to just clear the service-worker cache: inspect -> application -> clear storage

thheller 2020-12-17T13:54:17.002600Z

:release {:output-dir "somewhere/else"}

Shako Farhad 2020-12-17T13:55:06.002800Z

Ah! THat is wonderful! Thank you! I understand now. I am sorry for taking so much of your time. I appreciate your help!

2020-12-17T14:29:37.004500Z

Hello @thheller Since your proposition was not seleted, I wonder to know how to do without the convenient Shadow-CLJS's :default on vanilla CLJS. https://clojure.atlassian.net/browse/CLJS-2376

2020-12-17T14:30:10.004900Z

Hasn't that changed since the issue?

thheller 2020-12-17T14:30:25.005300Z

(:require ["foo$default" :as x]) will be the default solution but I don't think it is released yet

thheller 2020-12-17T14:31:11.006Z

vs (:require ["foo" :default x]). you can also always do (:require ["foo" :as x]) and then x/default

2020-12-17T14:34:23.007Z

Oh OK, I thought this issue was merged https://github.com/clojure/clojurescript/commit/f5f9b79f6f446cef768e190971cf67fc78bf5b93 Thanks for your help!

2020-12-17T14:40:46.007900Z

I just test with Krell and this don't works with this RN lib https://github.com/kmorales13/react-native-alarm-clock I'll try with RN Shadow-CJLS and see if it comes from the lib which may be specific.

2020-12-17T15:31:48.008200Z

@thheller So I just tried with Shadow-CLJS and your "reagent-react-native" repo.

(ns <http://test.app|test.app>
  (:require
    [shadow.react-native :refer (render-root)]
    ["react-native" :as rn]
    ["react" :as react]
    [reagent.core :as r]
    ["react-native-alarm-clock" :default AlarmClock]))

(defn create []
  (let [date (.toISOString (js/Date.))]
    (.createAlarm AlarmClock date "Alarm test")))

2020-12-17T15:32:26.008400Z

And I have this error

2020-12-17T15:33:04.008800Z

This lib seems specific right? https://github.com/kmorales13/react-native-alarm-clock/blob/master/src/index.tsx

2020-12-17T15:50:30.009100Z

A little idea @thheller please?

thheller 2020-12-17T15:57:09.009700Z

yes it is in master. just not in any official release I think.

๐Ÿ‘ 1
thheller 2020-12-17T15:59:04.009800Z

I don't have a clue. it might be ["react-native-alarm-clock" :as AlarmClock]?

thheller 2020-12-17T15:59:40.010Z

default exports are tricky sometimes because it also depends on how the library is bundled. looking at the code does not always match what the actual published package uses.

2020-12-17T16:04:54.010200Z

OK, I can see the published package provides 3 versions

2020-12-17T16:05:11.010600Z

How does CLJS do in this case?

2020-12-17T16:06:18.010900Z

CommonJS take predecence?

2020-12-17T16:08:57.011100Z

@thheller I think I have a lead. The CommonJS and module version export this var _default

2020-12-17T16:09:01.011300Z

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _reactNative = require("react-native");

const {
  AlarmClock
} = _reactNative.NativeModules;
var _default = AlarmClock;
exports.default = _default;
//# sourceMappingURL=index.js.map

valerauko 2020-12-17T16:18:23.012400Z

Hey @thheller could you please explain how shadow-cljs compiles dependencies? Users declare dependencies, you fetch them using aether... and then? How do the .cljc bits make it into the JS source code?

valerauko 2020-12-17T16:19:13.012500Z

I've been trying to read the source of shadow-cljs but couldn't find where this magic happens

thheller 2020-12-17T16:45:07.012700Z

not sure I understand the question

thheller 2020-12-17T16:45:15.012900Z

.cljc files are just source code somewhere on the classpath

thheller 2020-12-17T16:45:28.013100Z

so if you require the foo.bar somewhere in your code

thheller 2020-12-17T16:45:36.013300Z

it'll look for foo/bar.cljs or foo/bar.cljc

thheller 2020-12-17T16:46:06.013500Z

then it compiles those. code is in shadow.build.compiler

valerauko 2020-12-17T16:47:31.013700Z

But how do you acquire the cljc out of the jars? Do the jars contain the raw cljc files?

thheller 2020-12-17T16:47:40.013900Z

yes

thheller 2020-12-17T16:49:04.014100Z

the files are loaded via (<http://clojure.java.io/resource|clojure.java.io/resource> "foo/bar.cljc")

thheller 2020-12-17T16:49:22.014300Z

doesn't matter if its a regular file or in a jar. jvm classloader handles that.

valerauko 2020-12-17T16:49:29.014500Z

So basically you have maven (aether) fetch the jars (and unpack them?) then collect all the cljc/cljs files and give them to the compiler?

valerauko 2020-12-17T16:49:45.014700Z

The CLJS compiler can walk into jars?

thheller 2020-12-17T16:50:24.014900Z

it doesn't have to. the jvm classloader does.

thheller 2020-12-17T16:50:51.015100Z

jars are never unpacked (on disk, happens all in memory only)

valerauko 2020-12-17T16:53:21.015400Z

Ohh I see, jvm magic! Does the CLJS compiler look for cljs/cljc files on its own or do you have to feed it the files "manually"?

thheller 2020-12-17T17:06:06.015600Z

shadow-cljs will load and read them

valerauko 2020-12-17T17:21:37.015800Z

Awesome, I understand! Thanks a lot!

2020-12-17T20:35:46.016300Z

@thheller looks like http://shadow-cljs.org/ might be down? Not loading for me.

coby 2020-12-17T23:07:43.018200Z

is there a way to get browser tests to pretty-print failures, so that they're not all on one line like this? I'm guessing I would need a custom :ns-runner but beyond that it's hazy...

dpsutton 2020-12-17T23:11:05.018700Z

i think that's the output from @bhaumanโ€™s excellent cljs-test-display

coby 2020-12-17T23:27:15.018800Z

Checking that out, thanks for the tip!