Fork me on GitHub
#hoplon
<
2015-11-08
>
ulsa21:11:01

how do I handle cljsjs packaging with for example a data validation library with many external js files for each language, where I want to include the core library file and only some of the languages?

onetom21:11:58

sounds like the language files should be their own namespace, so u can require them independently

micha21:11:51

does the momentjs package handle that case?

micha21:11:06

i know it has lots of locale specific stuff

onetom21:11:43

indeed it does

micha22:11:03

you might need to use the sift task to get those, i don't remember if that was fully computed or not

micha22:11:23

but i think the :require separately scheme is the way to do it right

micha22:11:29

*correctly

ulsa22:11:39

it would have been nice from a migration standpoint to have the old hoplon5 way still available; I've been struggling with my 5 or so unsupported plugins for a while now

micha22:11:37

the old way required scanning all jars on the classpath, which can get really slow

micha22:11:00

we could bring it back with an option though, i suppose

micha22:11:28

or maybe better a boot task to perform the migration

ulsa22:11:42

is it still lexical ordering of the files in cljsjs?

micha22:11:02

no, it does dependency ordering, like .inc.js used to do

micha22:11:22

cljsjs is pretty much the same as .cin.js was, it was built on that

ulsa22:11:24

within a dependency I mean

micha22:11:40

no, there can't be such a thing

micha22:11:53

each js file must declare its own dependencies

micha22:11:59

and provide a namespace

ulsa22:11:45

ok, so jquery datatables which has ui variants for bootstrap, foundation etc, should all be different cljsjs packages?

micha22:11:08

well some js libraries are poorly designed, i dunno if that's the case there

micha22:11:24

but a normal library can be separated into the shared parts and the specific parts

micha22:11:33

like jquery-ui depends on jquery

micha22:11:38

for example

ulsa22:11:37

makes sense, but that just meant even more work for me

micha22:11:07

we can't build abstractions without a solid way to use transitive dependencies

micha22:11:34

it's worse than having nothing to have dependencies that don't work

micha22:11:51

for your own projects you can still just dump the files into the source paths

micha22:11:00

and make a deps.cljs file for them

ulsa22:11:28

that starts to look tempting

ulsa22:11:26

is there an example of such a project?

micha22:11:47

if you look at the cljsjs packages

micha22:11:52

you'll see a deps.cljs file

micha22:11:57

that's the thing you need to make

micha22:11:16

it should refer to classpath locations of the js files and externs

micha22:11:24

if you have externs

micha22:11:29

they're not strictly required

micha22:11:42

unless you want to do advanced optimizations

micha22:11:03

then you just put the js files in source paths where the compiler can see them on the classpath

micha22:11:19

and :require the namespace in your code that will use the external js

ulsa22:11:26

the last line there isn't clear to me

micha22:11:47

suppose you have a file, like index.cljs.hl for instance

micha22:11:35

(page "index.html"
  (:require [cljsjs.momentjs]))

(js/moment (new Date))

...

micha22:11:00

the js/moment thing won't work unless you do the :require [cljsjs.momentjs] part

micha22:11:20

this is because the deps.cljs file contains an entry with something like

micha22:11:23

{:file "js/moment.inc.js"
 :provides [cljsjs.momentjs]
 :requires [com.exampl.other-thing-moment-depends-on]}

micha22:11:37

does that make sense?

micha22:11:04

the deps.cljs file allows you to specify the dependency relations between external js files

micha22:11:20

which then allows you to use the compiler to bring that code in when you compile the cljs stuff

micha22:11:37

if you never :require that namespace then the compiler will not bring it into the compiled js

micha22:11:08

which is actually a good thing because it ensures that you don't end up with tons of js that you don't need being pulled in via transitive dependencies

ulsa22:11:44

and the deps file is placed where?

micha22:11:36

somewhere on the classpath

micha22:11:44

well in the root of the classpath

micha22:11:53

so in one of your source or resource dirs

micha22:11:16

it should be accessible via ( "deps.cljs") from the repl

ulsa22:11:51

ok, I get it

micha22:11:20

i think it would be possible to make a boot task that automates this mostly

micha22:11:38

pulls in the old style jars from maven and makes new ones

ulsa22:11:50

I use the auth exception stuff in tailrecursion.castra; are those somewhere else now?

micha22:11:06

yeah that was removed

micha22:11:18

it was complicated

micha22:11:34

there is just the one ex function now

micha22:11:13

it always sends back 200 responses and tunnels the exception inside

micha22:11:29

it can be caught in the client of course

ulsa22:11:50

and val-id is no longer recommended I take it? use let and local cells instead?

micha22:11:15

you can do like this now:

micha22:11:57

(input :change #(js/alert (str "the new value is " @%)))

micha22:11:21

it's extremely rare to want to actually fetch anything by id

ulsa22:11:10

can you explain the @% ?

micha22:11:48

the @ is a clojure reader macro: @% expands to (deref %)

ulsa22:11:55

of course

micha22:11:09

deref is a protocol, which we implemented on the jQuery Event type

micha22:11:20

which is what the argument to the event handler is

ulsa22:11:06

so it would be reset! local-cell @% then?

micha22:11:09

so @% is equivalent to (.. % -target -value) or something like that