Fork me on GitHub
#shadow-cljs
<
2019-12-12
>
isak00:12:23

> Namespaces that are known to include side-effecting macros can be blocked from caching. They won’t be cached themselves and namespaces requiring them will not be cached as well. The clara-rules library has side-effecting macros and is blocked by default. You can specify which namespaces to block globally via the :cache-blockers configuration. It expects a set of namespace symbols. @colinkahn @lilactown

👏 4
colinkahn00:12:53

Definitely trying this, thanks!

isak00:12:30

(from the docs)

colinkahn01:12:56

Not really having luck with :cache-blockers . I have: :cache-blockers #{cljs.spec.test.alpha clojure.spec.test.alpha}

4
thheller08:12:03

@colinkahn there is already special support in the caching layer regarding specs so this shouldn't be necessary

colinkahn15:12:47

@thheller besides using st/instrument a lot I don't think so. I set up replacement mock fns before each test case, but that doesn't seem like it should cause issues. Since there is some connection to the files in .shadow-cljs Is there something I can find in those files that might give a clue to what is causing it to break? I've looked in the folder but can't say I really understand what those files are doing.

thheller16:12:51

those are the cache files. each build has its own cache. and each namespace has its own cache file in .shadow-cljs/builds/<the-build-id>/dev/ana/...

thheller16:12:18

would help a lot to have something reproducible so I can see what you are actually doing

thheller16:12:31

there were issues in the past with specs defining specs for other namespaces and such

thheller16:12:43

maybe something along that lines broke

thheller16:12:47

kinda hard to say

colinkahn20:12:23

I was able to make it even more minimal. Reproducable with a single deftest without async:

(deftest test-1
  (st/unstrument)
  (is (= (set (st/instrument)) #{`app.core/foo})))

colinkahn20:12:07

I’m going to open an issue since I’ve played a bit more with this and don’t want keep posting stuff in here where it’s likely to get lost

thheller20:12:53

instrument is rather tricky in CLJS since its a macro that does a bunch of weird stuff

thheller20:12:08

not sure they are supposed to work as part of a "test"?

thheller20:12:21

but yes an issue would be good

colinkahn20:12:04

I split the files a bit more and played with :cache-blockers and was able to get it no longer fail.

colinkahn20:12:55

But I think you mentioned that clojure spec was treated differently for caching and it seems like files that use it are not ignored in the same way that using :cache-blockers does

thheller20:12:21

I'll take a look. maybe I missed a cljs.spec change or so

thheller20:12:25

thanks for the repro

👍 4
colinkahn22:12:24

@thheller saw you fixed it, thank you!

thheller08:12:24

are you doing anything special with those specs?

cfleming09:12:07

In Shadow, can builds specify their source paths, or are they always specified at the top-level? For example, if I have a test build and I want to include my test sources for that but not for my production build, can I do that?

thheller09:12:59

shadow-cljs by default only includes files in a build that are actually required somewhere

thheller09:12:15

so if your "production" build doesn't require any of the tests then it won't be in the build

cfleming09:12:25

Ok, great, thanks.

thheller09:12:36

but no there are no separate source paths per build

cfleming09:12:58

Ok, as long as I don’t actually need them that’s ok.

thheller09:12:49

you can always use deps.edn or project.clj to sort of get that but in regular use it shouldn't be required

cfleming09:12:23

No, as long as I know that this is the idiomatic solution I’m fine with that.

Michaël Salihi14:12:46

@thheller Hi Thomas, anything new about React-native and the websocket management ? Follow up your first pass about this the last summer ? > first pass to properly handle react-native not closing websockets

Michaël Salihi17:12:41

@thheller As you don't do React native, there are a new advanced hot reloading feature (fast refresh) : https://facebook.github.io/react-native/docs/fast-refresh Maybe we can use it to "fix" the websockets problem ?

thheller14:12:59

I added a few REPL helper fns but nothing automated yet

thheller14:12:27

dunno how ... the react-native issue I opened was closed due to inactivity and nobody ever looked at it

thheller14:12:46

IMHO its a react-native bug and I hate working arround other peoples bugs

thheller14:12:34

I added (shadow.cljs.devtools.api/repl-runtimes-clear) to kick out "stale" sessions

👍 4
thheller14:12:56

but funny enough .. the react-native websockets sometimes keep responding

Michaël Salihi14:12:06

> dunno how ... the react-native issue I opened was closed due to inactivity and nobody ever looked at it Yes, I see this 😖

thheller14:12:08

so they never go stale although the app was reloaded ...

thheller14:12:31

I don't do any react-native development myself so I never dug into it deeper

Michaël Salihi14:12:41

Thx for the information ! I will try about (shadow.cljs.devtools.api/repl-runtimes-clear)

Michaël Salihi15:12:55

> IMHO its a react-native bug and I hate working arround other peoples bugs Totally, I understand you

mauricio.szabo17:12:06

I'm having trouble using shadow-cljs, requiring a JS file that requires lodash. For example, if I have the following line on src/dependent.js:

import { size, isEqual } from 'lodash';
The following code on a .cljs file doesn't work:
(ns lod.main
  (:require ["/dependent" :as d]))

mauricio.szabo17:12:16

It fails with:

Closure compilation failed with 2 errors
--- dependent.js:1
Requested module does not have an export "isEqual".
--- dependent.js:1
Requested module does not have an export "size".

mauricio.szabo17:12:21

Is this a known issue?

thheller20:12:14

the issue is known yes. the closure compiler only really supports "strict" mode ESM interop so it complains when its fed commonjs code

thheller20:12:28

support works a bit better when using require and module.exports so CommonJS instead of ESM

thheller20:12:05

but that has other issues ... so doesn't work too well in other areas, mostly around requiring CLJS code from JS

Aleed00:12:09

so assuming we're mostly using js inside cljs (not cljs code in js), then commonjs is prefered to esm?