Fork me on GitHub
#clojurescript
<
2016-02-07
>
blissdev00:02:55

does anyone know of good open source examples of :foreign-libs being used to consume commonjs modules?

jaen07:02:22

if you don't control all the files IMO the better option is to just use webpack or browserify to compile the modules away.

jaen07:02:25

Maria's code can't deal with NPM modules as they are for example and supports only relative requires (the only module root it considers is .) IIRC.

samueldev14:02:39

morning cljs'ers

samueldev14:02:27

is there a way to debug this: #object[SyntheticKeyboardEvent [object Object]] // #object[SyntheticEvent [object Object]] without needing to install clairvoyant or clj-devtools?

joelkuiper14:02:47

What’s the preferred way of doing cache busting these days? I have a project in boot with LESS and Cljs resources, with an nginx reverse proxy that sets the cache expire headers, but I need some sort of cache busting (e.g. fingerprinting assets, ETags or something like it) so when we push a new version on prod the client-side cache gets invalidated

joelkuiper14:02:13

there seems several ways of doing this, but I’m unsure what’s the best/simplest. We use Selmer templating to load up the main page

martinklepsch14:02:21

@joelkuiper: on s3 i like fingerprinting which gives most fine grained invalidation control but many people just use a uri param

pandeiro15:02:26

@joelkuiper @martinklepsch Using boot it's pretty straightforward to transform compiled assets from main.js to main.<sha1>.js -- we use the pandect lib's sha1 fn

martinklepsch15:02:14

@pandeiro: right the fingerprinting itself is easy but then you need code that knows what paths to use for which objects etc

pandeiro15:02:42

right, we do the renaming and the transform of index.html in the same boot task

martinklepsch15:02:01

thinking of images in the cljs code etc

pandeiro15:02:09

(which is itself a composition of the sha1 computation, renaming, and html manip tasks)

martinklepsch15:02:13

but probably a good approach to dump some sort of "spec" in the html

martinklepsch15:02:40

and have functions to build asset paths in cljs that rely on this information

pandeiro15:02:39

in our case we work around this by inlining icons etc in the cljs files themselves

pandeiro15:02:41

since we don't have a ton of images or anything large, that works

blissdev18:02:11

@jaen thanks, so you’re saying I would need to build it into a static file and import that, and along the way probably make some externs?

jaen18:02:25

@blissdev: yes, that seems like the best idea IMO, given the current status quo. This might be instructive - https://github.com/taylorSando/om-material-ui

jaen18:02:03

The lib builds material-ui to a single file using scripts in build-mui and then uses that as a foreign lib.

jaen18:02:10

This for example might mean, you will not be able to use React from cljsjs, if the library needs to require it explicitly (like material-ui does)

blissdev18:02:24

This lib has no dependencies other than itself, so it shouldn’t be an issue.

blissdev18:02:09

Thanks @jaen that is really helpful

futuro20:02:54

@blissdev: you can describe external deps with browserify, which might be worth investigating if you want to continue to use the cljsjs version of react

futuro20:02:33

(technically react-with-addons, cause material-ui uses a couple react addons)

blissdev20:02:56

@futuro ah, I’m trying to apply the material-ui build procedures to a non-react javascript lib, so I don’t think that will be a concern

futuro20:02:15

blissdev: ahh, nice

blissdev20:02:35

trying to figure out what i need to do with externs

blissdev20:02:54

i imagine i can’t have browserify detect them, i’ll need to manually generate?

futuro20:02:03

to automatically generate externs for you. afaik, it loads the JS file then traverses the object you give it to figure out typing and so forth.

futuro20:02:38

@blissdev: I'd say that's a really good starting point, as it will get most of what you want, and then you can fill in the rest by hand

futuro20:02:57

there's also #C0E66E1H7, which you might be interested in

blissdev20:02:38

thanks, that is quite helpful

blissdev20:02:52

i actually asked on #C0E66E1H7 but it’s the weekend, so i understand no response yet

blissdev20:02:42

this will give me a solid start and i can see if i run into issues