Fork me on GitHub
#clojurescript
<
2017-05-01
>
hkjels15:05:13

https://gist.github.com/hkjels/ba240c989da00e06e3d0e536fc27a176 I’m sorry to bring up such a broad question, but I haven’t been able to create a minimized failing example yet

hkjels16:05:20

it ends up empty at times, even though it’s within the boundaries of the structure

hkjels16:05:21

the obvious part is the fact that it’s finite, but that’s not the issue I’m troubling with

mobileink16:05:08

hi, I need to generate URIs. I found https://github.com/cgore/gin which I think would work but I need a clojurescript version. anybody know of one?

mobileink16:05:46

thanks, I am using that, but I don’t see how to use it to generate e.g. random ipv6 addresses like “coap://[fe80::b1d6]:1111” - is that possible?

rauh16:05:43

@hkjels Looks fine to me

hkjels16:05:13

@rauh Thanks! I’ll have to investigate further this evening I guess

hkjels16:05:06

Great! I’ll give it a go )

crvst17:05:21

Hello there, would you recommend some beginner friendly video tutorials on Clojurescript. I've asked about them on the reddit and some guy suggested to ask you: https://www.reddit.com/r/Clojure/comments/68m6wq/any_good_video_tutorials_on_clojurescript/

crvst17:05:46

No need to explain about s-expressions, immutability and so on. But I cannot even consistently start brepl 😄 and do not know why

rauh17:05:20

@crvst What editor?

crvst17:05:29

Webstorm. Does it matter any?

rauh17:05:14

Well if you don't want to connect your editor to a REPL then no, it won't matter

crvst18:05:14

What is the purpose of connectiong REPL to editor? Just for a convenience? Is it the same that just keep editor and terminal with running REPL separately?

anthonyl18:05:53

I find it pretty handy to evaluate small chunks of logic in realtime

richiardiandrea19:05:04

Hello folks, so is anybody able to debug a node.js project with --inspect and Chrome DevTools?

darwin19:05:26

it should work

richiardiandrea19:05:37

It shows the .js files and says that source maps are there, but I don't see them in the file tree

richiardiandrea19:05:20

also, the sources key in the source map contains the file name only, not the path

anmonteiro19:05:26

@richiardiandrea did you install source-map-support in your project?

anmonteiro19:05:57

the compiler will try to require it but fail silently if it’s not available

richiardiandrea19:05:15

oh ok, I am trying

richiardiandrea19:05:43

trying source-map-support first

darwin19:05:44

last time I was trying to add support for node.js in Dirac I think this was a bummer

darwin19:05:01

ah, now I remember, node.js speaks about file-system paths when generating source-maps, but devtools understands only urls

darwin19:05:25

and it is unclear how to map file-system paths to urls in a general way (depends on your web server configuration of course)

darwin19:05:37

so this inlining works around it

thheller19:05:18

debugger works too

thheller19:05:26

@darwin the usual // #sourceMappingURL=foo.js.map works just fine?

richiardiandrea19:05:45

@thheller thanks! that might be how we'd go about eventually...but it would be great to understand why it is not working ootb

richiardiandrea19:05:33

so an example of generated sm is: {"version":3,"file":"\/Users\/user\/cqrs-engine-cljs\/out\/cqrs\/event_store.js","sources":["event_store.cljs"], ...

darwin19:05:41

@thheller I don’t remember the details, but I think the problem was inside the .map file, it used full file-system path for the orig src file

darwin19:05:48

ah, here you ^^^

richiardiandrea19:05:49

yes exactly 😄

darwin19:05:49

and setup a simple web server for serving source maps only

darwin19:05:04

maybe this:

darwin19:05:16

this worked for me 100%

richiardiandrea19:05:14

ok so basically is either your patch or serving the maps from a web server for now right?

darwin19:05:36

I knew I wrote something about it, oh memory 😉

richiardiandrea19:05:42

@darwin thanks! this should go on the main website I think

thheller19:05:17

uhm that conclusion seems wrong? I don't have a web server or anything running and source maps work just fine?

thheller19:05:54

maybe it doesn't like absolute paths but shadow-build generates source maps directly next to the sources and that works just fine

richiardiandrea19:05:23

@thheller I guess it is a workaround waiting for the patch above to be in?

darwin19:05:13

well, depends on options, maybe you are feeding cljs compiler with different defaults, try to reason about this code and let me know 😉 https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/compiler.cljc#L1232-L1247

thheller19:05:39

so demo/foo.cljs will have a demo/foo.js and a demo/foo.js.map where foo.js just links to //# sourceMappingURL=foo.js.map so never any paths in that link

thheller19:05:55

I don't use that code

darwin19:05:16

the problem is not //# sourceMappingURL= the problem is inside the .map file, whoever generated it

darwin19:05:33

.map file contains a reference to orig source file

richiardiandrea19:05:52

yep confirming the problem is the actual map, not the comment linking to it

thheller19:05:53

ah ok .. that code I also don't use 🙂

darwin19:05:57

usually this should be a relative url, but in node.js case, it is full file-system path

darwin19:05:38

the exact behaviour depends on cljs compiler options, :source-map-asset-path is a way to control that

thheller19:05:52

but IIRC the file property in the source map doesn't matter

thheller19:05:00

only the sources

darwin19:05:18

ok, maybe, but then something else didn’t click, devtools maybe expects the urls to be relative to server-root, but .map generator expects them to be generated.js relative or something like that

richiardiandrea19:05:27

@thheller oh ok so in my case {"version":3, ..., "sources":["event_store.cljs"] <- this guy is the problem ...

thheller19:05:37

yep confirmed, just changed my map to {"version":3,"file":"blubb/demo/script.js","sources":["script.cljs"],"lineCount":82 ...} and it still works

thheller19:05:47

blubb obviously doesn't exist

richiardiandrea19:05:16

ok cool so sources still need to be relativized I guess

thheller19:05:27

@richiardiandrea not if event_store.cljs and event_store.js + .map are in the same directory

darwin19:05:30

anyways, inlined source maps is the way how to avoid all these headaches. I’m out for now 🙂

richiardiandrea19:05:31

I think I need to read more on how they get resolved, to understand why this happens

richiardiandrea19:05:52

thanks for your hints

thheller19:05:48

you don't even need to configure source maps .. they just work 😉

richiardiandrea19:05:11

awesome the above is the easiest for sure

souenzzo23:05:14

(clj->js {"a/b" 33}) throws #object[Error Error: No protocol method IAssociative.-assoc defined for type cljs.core/EmptyList: ()]

souenzzo23:05:56

There is no easy way to integrate qualified keywords with plain json?

john23:05:19

Anyone ever have an issue with passing atoms into a js/setTimeout loop? I think I've done it many times before. I'm getting strange behavior where after one iteration of a loop, the atom (or whatever object) I'm passing in is not derefable.

john23:05:44

Uncaught Error: No protocol method IDeref.-deref defined for type undefined: 
    at Object.cljs$core$missing_protocol [as missing_protocol] (core.cljs:281)
    at Object.cljs$core$_deref [as _deref] (core.cljs:586)
    at cljs$core$deref (core.cljs:1364)
    at filo_ex$core$update_loop_time (core.cljs?rel=1493679699810:160)
    at core.cljs?rel=1493679699810:173

john23:05:33

here's the function that is called within a js/setTimeout loop:

(defn update-loop-time [time-atom]
  (let [old-time (:time @time-atom)
        new-time (.getTime (js/Date.))
        diff (apply str (take 4 (str (/ 1000 (- new-time old-time)))))]
    (swap! time-atom assoc :time new-time)
    (swap! time-atom assoc :text diff)))
not sure if that'd help any. I don't see any obvious issues there.

john23:05:13

It seems like my swap! statement must be clobbering the atom, because I'm not mutating the atom anywhere else in the program. But the function looks fine afaict

john23:05:10

@souenzzo (clj->js {"a/b" 33}) works on my repl.

john23:05:01

;=> #js {:a/b 33}

souenzzo23:05:00

at lumo 482 works here too 🙂 ... I't sould be chrome or 521 bug

john23:05:49

I'm on chrome with cljs 1.9.518

john23:05:45

oooooh, I wasn't passing the time atom back into the js/setTimeout function. duh

john23:05:14

thus, only one iteration

souenzzo23:05:17

My problem: how to use qualified keywords with a JSON API (clojurescript + golang) My first try: - let's rename backend "keywords". Now json was {"user/name": "souenzzo"}. - #(js->clj % :keywordize-keys true) awesome: {:user/name "souenzzo} - Now it's just generate JSON from EDN: -> (clj->js {:user/name "souenzzo"}) => {"name": "souenzzo"} -> (with-redefs [name str] (clj->js {:user/name "souenzzo"})) => {":user/name": "souenzzo"} (note extra :) Is that hard to make it? I'm missing something?

richiardiandrea23:05:32

for folks, my problem with source maps was with node.js 6.10.2. Everything works ootb with 7.9.0 probably something changed in node-inspect (which got bundled as well)

richiardiandrea23:05:59

Probably @darwin with this new version you don't need to use a webserver but I haven't tried Dirac yet