Fork me on GitHub
#clojurescript
<
2016-01-07
>
yaniv00:01:03

so my only option is to not have any externals and then it’ll bundle multiple copies

jaen00:01:06

If you expose js/React from your foreign lib and shim cljs.react with an empty file you should probably be good. So you can just use the one in your bundle.

jaen00:01:57

Libs like reagent and such just pick it up from that global.

yaniv00:01:18

okay globals it is

jaen00:01:49

At least it was the case with for e.g reagent 0.5.0, 0.6.0 might have changed that since they updated to React 0.14

yaniv00:01:43

they were doing some interesting stuff in that update. looking at this commit https://github.com/reagent-project/reagent/commit/d9ad7740ecf176c0c82943898b4abb5d3c6df81b

jaen00:01:54

Yeah, looking at that, it seems quite a bit has changed indeed.

yaniv00:01:11

i see. they export a manufactured “require" global that takes the string and returns the module. and then they call js/require from cljs

yaniv00:01:49

still some weirdness in that setup though. they’re not using UMD and not using :module-type commonjs and i don’t see how their module can :provide “cljsjs.react"

jaen00:01:58

I think those are there just for Clojurescript compiler's dependency resolution mechanism so it knows the foreign lib was required when deciding what sources to output.

jaen00:01:09

So it's just basically a dummy value (in that it doesn't relate to whatever the file may expose globally or not).

jaen00:01:58

But I might have misunderstood/misremembered the source.

dnolen00:01:14

@yaniv @jaen yes :provides for foreign libs is fabricated thing - foreign libs are always global imports

jaen00:01:37

Oh, so I got that right at least.

dnolen00:01:54

:provides for foreign libs is just a key so the compiler knows what file to actually require

yaniv00:01:50

i see makes sense

eyelidlessness02:01:30

a thing i don't understand:

(def e (js/Error. "welp"))
(.-constructor e) ;; nil

eyelidlessness02:01:48

does .- not do normal property access (delegating to the prototype chain)?

eyelidlessness02:01:04

if not, is there a way to do that?

maria02:01:47

@eyelidlessness: mhh, works for me. Where are you running this example?

maria02:01:52

mneise$ planck
cljs.user=> (def e (js/Error. "welp"))
#'cljs.user/e
cljs.user=> (.-constructor e)
#object[Error "function Error() {
    [native code]
}”]

eyelidlessness02:01:03

tried it on the http://clojurescript.net/ web repl to isolate it, but i'm coming back to it from earlier and i swear i encountered it in my own cljs code as well

eyelidlessness02:01:02

but it works for me locally now, and in a local repl

eyelidlessness02:01:22

so maybe i was just using the web repl for convenience, and it's an oddity of bootstrapped cljs?

maria02:01:47

@eyelidlessness: well, planck is also using bootstrapped cljs, so not sure what the problem is in http://clojurescript.net/

maria02:01:23

accessing (.-message e) or (.-name e) works fine on the other hand

eyelidlessness02:01:40

thanks for the sanity check. it's a relief that it's not a limitation of .-

eyelidlessness02:01:00

yeah i noticed that, but those are direct properties, which is why i suspected it was avoiding the prototype chain somehow

maria02:01:46

name doesn’t seem to be a direct property

maria02:01:54

cljs.user=> (.hasOwnProperty e "message")
true
cljs.user=> (.hasOwnProperty e "name")
false

maria02:01:48

but yes, could be a problem in a previous version of bootstrapped clojurescript, since http://clojurescript.net/ is most likely using an earlier version of it

eyelidlessness02:01:12

interesting. i guess i didn't really pay attention to name, which i wasn't even aware was a property on js errors

eyelidlessness03:01:52

it does appear to be a difference in behavior across versions then. (.-consctructor e) def works on http://clojurescript.io

eyelidlessness03:01:08

thanks for pointing out the other web repl

mfikes03:01:07

*clojurescript-version* is always set in ClojureScript environments

richiardiandrea04:01:54

BTW http://clojurescript.io uses the last replumb which is an improved version of Joel Martin's code for http://clojurescript.net

richiardiandrea05:01:21

I am now working on bundling the necessary sources so that require will work smoothly on it. It will lakely be a boot task that produces the necessary file set.

danielgrosse09:01:11

How can I limit the results of a query. I want only show the ten last items

jaen09:01:03

That's rather vague (what sort of query?), but you probably could do (take-last 10 coll) or something.

jethroksy09:01:29

You can do this in the sql query as well, if sql

danielgrosse13:01:28

@jaen It was take, I needed.

danielgrosse13:01:37

Are there solutions for adding version numbers to the compiled files, to prevent caching issues?

jethroksy13:01:54

what tool are you using to compile your cljs?

mfikes13:01:30

@danielgrosse: When compiling, the emitted JavaScript files have a comment at the top containing the ClojureScript version number along with other compiler options that are relevant to cache validity.

danielgrosse13:01:01

So there won't be issues, when updating files?

mfikes13:01:09

This handles the case where you are developing, have cached JavaScript files in your dev environment, and then change compiler options (say :static-fns for example), or even update to a new version of ClojureScript. This will cause those cached files to become invalid.

danielgrosse13:01:49

And when I deploy the combined files on the server?

mfikes13:01:58

Hrm. My response was limited to what occurs in dev and how the compiler behaves.

mfikes13:01:53

If you are using a single :advanced file for deployment that probably makes the answer simpler.

danielgrosse13:01:49

Yes I compile to a single file.

mfikes13:01:23

I’m not familiar with how ClojureScript behaves in web environments… suspect many others here are intimate with that aspect.

jethroksy13:01:15

boot eliminates the issue of stale files with their tooling structure and immutable filesets

danielgrosse13:01:48

So i will see, how I can implement boot into my workflow

jethroksy13:01:14

what are you currently using to compile your cljs though

jethroksy13:01:18

the jar file? lein?

jaen13:01:43

@danielgrosse: if you would want try boot then this introduction is pretty good - https://github.com/magomimmo/modern-cljs/tree/master/doc/second-edition

jaen13:01:00

Also you can take a look at project templates like tenzing and sapas.

meow13:01:57

there is also great boot support on the #C053K90BR channel

nberger17:01:57

sent a patch to fix a hidden minor bug in the 1-arity version of js->clj: http://dev.clojure.org/jira/browse/CLJS-1540. If you ever tried to pass {:keywordize-keys true} and it didn't work as you expected, that's why

kopasetik17:01:41

Does cljs have the same inaccuracy issues with floats as Javascript?

kopasetik17:01:36

@nberger: Thanks! That’s unfortunate though 😕

dnolen17:01:44

@kopasetik: for perf reasons we do not attempt to do anything about JS numerics

dnolen17:01:14

however there’s been talk of fixing this in JS itself in TC-39 - so we’ll just get it when everyone gets it

kopasetik17:01:07

@dnolen: Fair enough. Looking forward to the day that I can do "real math" in a JS environment without a library!

iwankaramazow19:01:54

does anybody know if it's possible to partially load an app with google closure modules? Webpack w/ React Router partial app loading trough require.ensure is all the rage these days.

iwankaramazow19:01:13

Any ideas on how I could achieve this with clojurescript?

dnolen19:01:43

@iwankaramazow: @arohner wrote a blog post about loading only the parts that matter when you need them.

dnolen19:01:35

@iwankaramazow: Google Closure has supported this pattern for probably 5 years

iwankaramazow19:01:54

Wow, thanks! 😀

dnolen19:01:52

I’m thinking about cutting a new ClojureScript release tomorrow, it’s been about 2 months since the last official one - if you have time to test master that would be great simple_smile

dnolen19:01:32

one big new feature - parallel compilation (which still needs more tire-kicking) but I’ve been using it and it seems to work well enough

dnolen19:01:56

the other is much better handling by the compiler of changing dependencies - you should not have to blow away the build any more if you change a dependency

iwankaramazow19:01:40

I'll check it out tomorrow, really looking forward to the parallel compilation 💪 💪

dnolen19:01:52

@iwankaramazow: the benefit at the moment is mostly for cold development builds

dnolen19:01:09

eventually would like to get it working for REPLs but I don’t want to stall this release anymore

iwankaramazow19:01:54

Even in cold dev env this will be awesome

grav21:01:11

Can I exclude certain namespaces when doing a build with cljs.build.api/build?

grav21:01:24

Or include certain ns’es as an alternative?

dnolen21:01:35

@grav there’s no way to exclude specific namespaces

grav21:01:36

I want to create a custom build script that just compiles one namespace for nodejs that isn’t web-specific, whereas the rest of the code contains some reagent stuff

dnolen21:01:59

well not by enumerating them anyway

dnolen21:01:12

but you can use the classpath to control what does and doesn’t get lumped into your build

dnolen21:01:19

:main is also another way to control this

grav21:01:31

Ok, I’ll look into that!

grav21:01:57

How about using cljsbuild and then specifying multiple :source-paths for the web-part and only one for the nodejs-part? Does that make sense?

grav21:01:16

Seems cljsbuild supports nodejs

dnolen21:01:32

@grav yes, sorry that’s what I was suggesting

dnolen21:01:50

you can pass different inputs, or with cljsbuild use different :source-paths

mfikes22:01:55

Dang. I wish Sussman would show up at one of my local Clojure Meetups. I gotta move to NYC where stuff's happenin' :)

kingoftheknoll22:01:31

wondering if I could get some repl guidance. Started an Om project using the Chestnut lein template. Everything works great except that when in the my-app.core ns I can’t eval any form and I get this error Unable to resolve symbol: app-state in this context I get the error from both cider and lein repl

dnolen22:01:30

@kingoftheknoll: sounds like you are evaluating ClojureScript as Clojure

dnolen22:01:38

that error doesn’t exist in ClojureScript

kingoftheknoll22:01:54

ah well that would do it

kingoftheknoll22:01:05

I would think starting the cider repl from that file would start a cljs repl. Any pointers on where I can read more about this?

kingoftheknoll22:01:27

also @dnolen big fan of your talks they were my gateway drug

dnolen22:01:33

@kingoftheknoll: cool! I can’t help there I haven’t followed the cider CLJS developments closely being a Cursive person now. Somebody else might know though.

kingoftheknoll22:01:20

thanks I’ll keep at it!

kingoftheknoll22:01:13

btw I think I found the problem. Chestnut builds a template where all the dependencies are woefully outdated

kingoftheknoll22:01:28

that is after I got into the cljs repl I discovered this

danielcompton23:01:34

@dnolen: as I mentioned a while ago we’ve been getting crashes with parallel compilation (probably exposing latent bugs or bad configurations), will try to look at it again on our projects when I’m back at work

dnolen23:01:14

@danielcompton: yeah so far only heard that from you

dnolen23:01:28

and no minimal case so until I get that, nothing for me to consider

virmundi23:01:00

hello. may I ask questions about figwheel here?