Fork me on GitHub
#shadow-cljs
<
2018-04-19
>
emccue06:04:18

Im trying to get started with shadow cljs and im using the re-frame example

emccue06:04:30

The example works beautifully, and with the skeleton project.clj cursive picks everything up just fin

emccue06:04:32

but when I try to use semantic-ui-react I get a "Uncaught ReferenceError: require is not defined"

emccue06:04:49

I am running through yarn watch

cmal06:04:48

@thheller Yesterday's problem shadow-cljs watch app slow appear again: it takes a long delay before each of two Cache write: xxx/xxx.cljs , but the times are not reported.

cmal06:04:15

shall I update the version of shadow-cljs first? 2.2.26 now

cmal06:04:27

updated to 2.3.0

thheller07:04:42

@emccue you are using ancient versions in the project.clj. definitely upgrade all of them before continuing.

thheller07:04:26

latest shadow-cljs is 2.3.0

cmal08:04:25

maybe because during shadow-cljs watch app1, I shadow-cljs release app2 (another app)?

thheller09:04:30

@cmal not really. each build has its own cache directory so they don't interfere with each other

thheller09:04:34

there could be one possible problem looking at the code

thheller09:04:46

do you use cljs.spec in both apps?

cmal09:04:00

only in one

cmal09:04:22

not in the slow app.

cmal09:04:13

I will keep one eye on this problem, and try to figure out what happens when it becomes slow.

thheller09:04:45

currently the cache-write only logs when it completed, not when it started so I assume that the cache write itself is just slow since its not timed

thheller09:04:03

the cache is potentially writing a lot of data.

thheller09:04:40

can you check how large the .shadow-cljs/builds/app1/dev/ana/your/ns.cljs.cache.transit.json is?

thheller09:04:00

maybe it is getting excessively large for some reason

thheller09:04:38

are you maybe running low on disk space? the OS might get into real trouble with the FS then

cmal09:04:57

du -sh 33M

thheller09:04:05

hmm thats normal

cmal09:04:07

in /builds

cmal09:04:31

Free disk space 15.8GB

thheller09:04:18

hmm yeah thats all ok then

thheller09:04:03

I will expand the timing log for cache reads/writes so get more accurate infos about that

thheller09:04:31

but still not a clue what could be causing this

cmal09:04:32

OK. I'll keep on my using and see what happens when it becomes slow.

cmal09:04:39

Thank you so much.

gnl13:04:40

How can I use alternative artifacts providing the same namespaces and API in dev and production, e.g. day8.re-frame/tracing and /tracing-stubs?

gnl13:04:39

In leiningen it's generally done different :dependencies in each profile but that doesn't seem possible in shadow-cljs. Am I missing something?

gnl13:04:50

^done with

thheller14:04:04

@clojurians.net I think this approach is pretty terrible and yes with just standard shadow-cljs this is not possible

thheller14:04:18

you can do it if you use lein or deps.edn

thheller14:04:11

I will look into what exactly the re-frame trace stuff is doing and see if there isn't an alternative way

gnl14:04:50

There's also https://github.com/philoskim/debux-stubs I'm not a great fan of it either, but it strikes me as the most reliable way to make sure that tracing/debugging code doesn't end up in a production build. It is theoretically possible to leverage Closure's dead code elimination for that, but I believe there have been issues with it in the past and it's quite a bit more messy and error prone.

thheller14:04:51

devcards does this via :devcards true. this seems more suitable since its just a compiler options.

thheller14:04:12

I would not trust DCE fully either

thheller14:04:00

the macro stuff could just eliminate based on the compiler setting

gnl14:04:50

Yeah that does sound cleaner. In the meantime, for projects that do it the other way, I'm guessing this would be the way to go: lein with-profile +<dev/prod> run -m shadow.cljs.devtools.cli ...

gnl14:04:29

Great, thank you.

emccue15:04:43

@thheller it was an obvious fix but it worked, thank you

thheller15:04:27

@emccue how come you picked that particular version? is it still used in an example somewhere?

colindresj17:04:36

Is it possible to use preloads with :target npm-module?

emccue18:04:04

Yeah it was used in whatever example I pulled this from

emccue18:04:46

it is in the example project.clj

emccue18:04:09

...somewhere

emccue18:04:16

I dont know

thheller20:04:01

@colindresj no since there is no clearly defined entry they should be preloaded for

levitanong20:04:10

@thheller According to the shadow-cljs docs, i should be able to copy the some fulcro source file, place it in my own project matching the directory structure of where it would’ve been were it in fulcro, make some change, and it would be using that instead of the actual lib. It seems this file is being ignored. Are there any known gotchas about this? I’m specifically trying to work on fulcro.client.primitives.cljc. I’ll be going off to bed now. Dropping this message hoping to catch you during your day, because timezones.

thheller20:04:20

@levitanong you mean fulcro/client/primitives.cljc

thheller20:04:24

slashes not dots

thheller20:04:47

and yes if you put it into your classpath like that it should work

colindresj20:04:40

That’s what I thought @thheller. Any idea how I might integrate https://github.com/Day8/re-frame-10x into a storybook build?

danielcompton20:04:29

@colindresj not sure what a storybook build is, but there’s an example of this usage on https://github.com/jacekschae/conduit

colindresj20:04:22

Storybook’s is a kind of like a react component dev environment @danielcompton. It’s a JS lib though, so I’ve been using the npm-module shadow target to get my cljs code to work with it, but now want to include re-frame-10x and I’m having a little trouble

colindresj20:04:10

I tried just requiring the compiled re_frame_10x.preload namespace, but it I get some react rendering errors when doing that, something about vbox not returning a valid component

thheller20:04:09

@colindresj I don't remember if it was possible to influence which files storybook loads. IIRC it is just looking for files with a regexp

thheller20:04:33

you could probably just require re-frame-10x.preload in your stories namespace?

colindresj20:04:47

Yeah, that’s what I did

colindresj20:04:11

And namespace-wise everything seems good, but then I run into that react rendering errror, so I feel like something’s up

thheller20:04:12

did you set the proper :closure-defines?

colindresj20:04:33

Yeah, and just for testing I removed it and got the 10x warning telling me to set closure defines

colindresj20:04:41

So, I think that part’s good

thheller20:04:00

hmm maybe something in re-frame-10x doesn't like how storybook loads the code?

colindresj20:04:12

That’s what I’m thinking, or vice versa

colindresj20:04:13

For reference, this is my error @danielcompton Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of day8.re_frame_10x.utils.re_com.v_box

danielcompton21:04:57

@colindresj have you chosen the right version of re-frame which matches your React version?

danielcompton21:04:02

If you can't get it working, open an issue with a reproduction

colindresj22:04:15

Ok, will do. Thanks