Fork me on GitHub
#clojurescript
<
2015-09-25
>
shofetim00:09:41

lvh I'm using clojurescript 1.7.122 and am able to import and use goog.dom.xml

lvh00:09:52

wait, import?

lvh00:09:09

What exactly are you doing to get it?

lvh00:09:36

I’m trying to (require ‘[goog.dom.xml :as gxml])

lvh00:09:53

thanks for that smart quote, slack

shofetim00:09:55

Sorry, require. Nothing special

shofetim00:09:58

Your require form works for me at at cljs repl as well.

lvh00:09:28

how are you using it? gxml/loadXml or something?

lvh00:09:33

or just looking at gxml itself

lvh00:09:01

goog.dom definitely works

shofetim00:09:35

(require '[goog.dom.xml :as xml]) (print (xml/loadXml "<body></body>"))

shofetim00:09:41

works at cljs repl

lvh00:09:36

maybe this is just figwheel being weird

lvh00:09:52

I’ll try and cut that out

lvh00:09:03

shofetim: thanks for all the help & patience simple_smile

shofetim00:09:29

^shrug^ my cljs repl is a figwheel repl....

lvh00:09:51

eh, okay, so refreshing the page made it work

raspasov05:09:20

hey guys, is it possible to find out the line number of an error when I get that error in a minified Google Closure Compiler file?

sander06:09:00

in Quick Start, the example node_repl.clj doesn’t include :target :nodejs in the cljs.build.api/build spec. therefore, after running it, node out/main.js doesn’t work since it’s built for the browser. can i fix the tutorial or am i wrong?

danielcompton06:09:31

@raspasov: have you got sourcemaps setup?

val_waeselynck10:09:56

@raspasov: yes source maps work with advanced compilation too.

bteuber10:09:07

Hi, did anyone succeed in using cider with the newest figwheel?

bteuber10:09:17

I've setup a (failing) test project for that, see https://github.com/bsteuber/ciderfig

colin.yates10:09:36

let me find a link...

colin.yates10:09:16

@bteuber: some good notes in https://github.com/bhauman/lein-figwheel/issues/244 - my (semi-working config is in the last comment)

bteuber10:09:11

ah interesting, it's with sidecar instead of piggieback

bteuber10:09:28

still getting errors on compile, but I'll experiment more

colin.yates10:09:01

yeah, 0.4.0 no longer hard-depends on piggieback so you need to add that in

bteuber10:09:02

ah I need it and still start sidecar instead?

colin.yates10:09:47

and the front page for piggieback and figwheel github projects

colin.yates10:09:06

but I certainly haven’t studied all the different options in depth.

borkdude10:09:28

what are the most notable differences when compiling for nodejs instead of browser?

borkdude10:09:54

I mean: what differences are inside the generated javascript. Requires probably

bteuber10:09:00

@colin.yates: btw. what do you mean "semi-work"? simple_smile Sth. like getting an ns-as-map dispatch error every now and then?

colin.yates10:09:34

no, I don’t get that, but if I open up a Clojure and a ClojureScript REPL then all evaluation goes to the Clojure REPL.

mitchelkuijpers11:09:35

I wanted to share this little gem:

(goog.string/createUniqueString)
extremely usefull when wrapping js component which demand id's

mitchelkuijpers12:09:03

Ow just figured out gensym

aleksander12:09:29

Hi everyone, I'm looking for an explanation on how do figwheel, piggieback, weasel, austin, nrepl, sidecar etc compliment/differ/overlap with each other. ATM I'm using figwheel and realised I probably need piggieback to make it work with vim-fireplace. I'm still confused though which part does what and what would constitute a good setup.

nha12:09:18

Hello, anyone knows what mori-export does and the difference in using that vs (def ^:export ...) ? https://github.com/swannodette/mori/blob/master/src/mori/macros.clj#L18

spinningtopsofdoom13:09:46

From the looks of the macro it looks like it specializes on arity for speed i.e. assoc and assoc.f3

nha13:09:04

Thanks @spinningtopsofdoom . So it is basically equivalent to ^:export but more performant ? Is there a tradeoff that you are aware of (or can we expect :export to behave like that in the future) ?

nha13:09:52

Ah I see now, thanks for the link.

nha13:09:48

Are arguments passed from javascript to clojurescript alway copied ? Or only when using js->clj, or on the first time we assoc something to it ?

nha13:09:37

(I’m asking in the general case, not for mori)

spinningtopsofdoom14:09:00

If you're talking about arguments passed to a compiled CLJS function (e.g. CLJS (ns foo) (def ^:export bar [n] (assoc n :a 1 ) and JS foo.bar(null)) then the arguments are passed in as is just like normal JS. No conversion or copying is done.

nha14:09:39

@spinningtopsofdoom: thanks for the confirmation simple_smile

spinningtopsofdoom14:09:02

NP glad I can help

asolovyov14:09:37

hey all! So I wonder if it's possible to have something like :preamble, but for :optimizations :none? I need some polyfills for nodejs and I'm not really sure what's the best way to install them...

spinningtopsofdoom14:09:37

@asolovyov: I'd look at the Google Closure library first to see if the polyfill exists there. Look at`:foriegn-libs` for polyfills from third party JS https://github.com/clojure/clojurescript/wiki/Dependencies

asolovyov14:09:13

@spinningtopsofdoom: my polyfill is literally 5 lines of javascript, I just don't know how to apply it nicely

asolovyov14:09:30

just requiring it at the top unfortunately doesn't work, namespaces load in weird order anyway

asolovyov14:09:44

so I need something that will load before all namespaces

asolovyov14:09:01

ideally - that I'll add it to my main.js (which is :output-to) at the top

spinningtopsofdoom14:09:28

The link I sent you shows how to polyfill (the example used is around the size of the code you're talking about)

asolovyov14:09:56

so if I add it to :foreign-libs, it'll be loaded before everything?

delaguardo14:09:22

This can help for eval 5 lines of js

asolovyov14:09:23

@delaguardo: js* is what I use! But namespace with it loads too late!

asolovyov14:09:54

@spinningtopsofdoom: I'm not sure I see how :foreign-libs will help me...

asolovyov14:09:01

it's not better than just regular cljs ns

spinningtopsofdoom14:09:41

Put the JS polyfill you need in a file and then reference that file from the CLJS compiler.

spinningtopsofdoom14:09:58

If you want to use it like a normal CLJS file then put a goog.provide("my.ns") on the top of the file. Don't use js* it's an implementation detail for CLJS and can ply havoc with your code later on

asolovyov14:09:19

that will work, but it won't do anything for me

asolovyov14:09:28

because it'll be required like a normal namespace

asolovyov14:09:38

whenever compiler wants it

asolovyov14:09:45

I need something to be required before every other ns

spinningtopsofdoom14:09:08

Sorry misread that you needed it to load before all other ns. If you need it for :optimizations :none why not use <src="mypolyfill.js"></script>?

spinningtopsofdoom14:09:25

before your CLJS is loaded

spinningtopsofdoom14:09:30

I'm assuming you're needing this for a browser since you're talking about a nodejs polyfill

asolovyov14:09:02

@spinningtopsofdoom: because I don't have any html, that's shim for node.js

asolovyov14:09:28

i define window there, localStorage, stuff like that

asolovyov14:09:31

just basic stuff

spinningtopsofdoom14:09:55

Ah I read your needs backwards. You have :main :my.ns if you're using :optimizations :none, correct?

dnolen14:09:10

@asolovyov: this is what :preamble is for.

asolovyov14:09:26

@dnolen: yeah, but I need :optimizations :none for development simple_smile

dnolen14:09:28

if that doesn’t work then just a bug and happy to take a patch for that

asolovyov14:09:41

and preamble doesn't work in that case...

asolovyov14:09:47

because that's by design!

asolovyov15:09:08

@dnolen: I wonder if I can execute some code before requiring some namespace?

dnolen15:09:31

@asolovyov: there’s no reason to not support :preamble under :none

asolovyov15:09:50

it could've been written to the :output-to, right?

asolovyov15:09:00

that makes quite a bit of sense simple_smile

asolovyov15:09:05

I'll try to contribute then!

dnolen15:09:48

@asolovyov: actually it appears this was already fixed in master by @pupeno simple_smile

asolovyov15:09:06

@dnolen: then when the release is coming? :-))

dnolen15:09:19

I might cut a release soon as it’s been a while

asolovyov15:09:29

because I'm not sure I see how it makes :preamble work...

dnolen15:09:37

@asolovyov: it calls cljs.closure/add-header under Node.js and c.c/add-header calls c.c/make-preamble

dnolen15:09:36

unless I misread, you should definitely test it yourself to confirm though

asolovyov15:09:46

right, I'll do that now

asolovyov15:09:29

@dnolen: sorry, am I doing this right? java -cp ~/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar:~/.m2/repository/org/clojure/clojurescript/0.0-SNAPSHOT/clojurescript-0.0-SNAPSHOT.jar:src/mk/fe:src-node clojure.main build.clj it says Could not locate cljs/build/api__init.class or cljs/build/api.clj on classpath. my require has single quote, obviously simple_smile

dnolen15:09:11

@asolovyov: I wouldn’t do it that way

dnolen15:09:29

run ./script/build

asolovyov15:09:43

had no idea about it simple_smile

dnolen15:09:45

note version that gets installed in your local Maven, use this version in your project.clj

asolovyov15:09:35

right, it just my cljsbuild spits out error which is not really understandable, so I'm trying to get nude cljs to work, so that I can read original stuff

asolovyov15:09:08

@dnolen: do I then use -aot version after script/build?

dnolen15:09:56

@asolovyov: if you’re trying to do a minimal check as above then use ./script/uberjar

dnolen15:09:04

this will create target/cljs.jar use this jar

asolovyov15:09:56

@dnolen: ok, I can report that everything works simple_smile

verma17:09:59

@gigasquid: you are needed at the book signing

mbertheau19:09:09

In the boot cljs repl how do I enable the :repl-verbose option of the clojurescript compiler?

timgilbert20:09:08

Probably a dumb question: what's the easiest / clearest way to serialize and unserialize ClojureScript data to a string? I want to attach a small map to a dataTransfer object on a drag event

timgilbert20:09:28

I guess (cljs.reader.read-string)?

pandeiro20:09:17

@timgilbert: that's what i use

timgilbert20:09:49

Thanks @pandeiro. Are you just using (str) to serialize?

pandeiro20:09:03

usually (pr-str ...)

timgilbert20:09:58

Ah, that makes sense. Thanks!

colin.yates21:09:37

hi all - I am using transit (json) to send messages from the server to the client and it is working great except my UUIDs don’t seem to be coming across:

colin.yates21:09:42

cljs.user=> id #uuid "9e7200f4-419c-461e-a9e5-f6b07f8dcd8f" cljs.user=> (type id) #object[Function "function (high, low) { this.high = high; this.low = low; this.hashCode = -1; }"]

colin.yates21:09:08

previously (type id) would return cljs.core/UUID)

colin.yates21:09:30

according to transit UUIDs should be transformed automatically, but it seems they aren’t - any suggestions?

colin.yates21:09:58

I forgot this is a bit of ghost town whilst everybody parties at the conference so I have also posted to https://groups.google.com/d/msg/clojurescript/_B52tadgUgw/7r6uCh_EBgAJ simple_smile

colin.yates22:09:22

that looks like it might be it - thanks @jaen!

iwillig22:09:30

does doing adding a handler fix your issue ? { :handlers { "u" uuid } }

iwillig22:09:53

sorry this is a second arg to the read function in transit-cljs

colin.yates22:09:09

I haven’t tried - I am just about to crawl up to bed to be honest (midnight here and a long day :-)). I will try first thing tomorrow morning though.

colin.yates22:09:33

It isn’t a great deal if the type has changed, it just made me think ‘woah…’ that’s all.

colin.yates22:09:41

but thank you for your help

colin.yates22:09:54

(currently battling immutant and wildfly)

iwillig22:09:04

i think it might be because they add a real uuid type to clojurescript recently

colin.yates22:09:13

wasn’t cljs.core.UUID a ‘real’ type?

colin.yates22:09:24

(that sounded snarky, it wasn’t meant to :-)).

iwillig22:09:02

not sure... it was a type but did not have a constructor function maybe

iwillig22:09:25

actually i might take that back... its after beer time so i am not sure how helpful i am 😉

colin.yates22:09:29

he he - beer and tiredness - that’s when the most amazing coding sessions happen!

iwillig22:09:40

never mind i just check the git history in cljs.core and that does not seem to be the case

colin.yates23:09:50

actually, I just realised that the http://README.org on https://github.com/cognitect/transit-cljs just explicitly state the types, and yes they are com.cognitect.transit. I should have noticed that - bleary eyed.