Fork me on GitHub
#clojurescript
<
2017-01-05
>
eyelidlessness00:01:24

is there a specific list of field names that are preserved for .method/`.-prop` with advanced compilation?

cfleming00:01:57

@tbaldridge I’ll be doing that shortly as part of better CLJS REPL support.

cfleming00:01:07

It’s mostly a UI problem rather than a technical one.

eyelidlessness00:01:19

@darwin i literally just found that. thanks!

darwin00:01:32

not much useful, because it depends on closure compiler version

eyelidlessness00:01:05

trying to track down what is likely a munging of some DOM property in the drag-and-drop API

eyelidlessness00:01:23

without waiting for dozens of slow compiles to isolate it

darwin00:01:13

I see your pain 🙂

darwin00:01:34

[shameless plug] checkout my library https://github.com/binaryage/cljs-oops

eyelidlessness00:01:57

@darwin i’ve seen that and considered using it!

eyelidlessness00:01:23

may still yet, but not ready for that big a change just yet

eyelidlessness00:01:46

what kind of impact does it have on page weight? have you measured?

eyelidlessness00:01:18

i would imagine it’s quite small

darwin00:01:22

under :advanced builds it boils down to aget calls you would write by hand

darwin00:01:50

under dev builds it bloats every call site with diagnostics code

eyelidlessness00:01:37

how does it work? i started looking at source then saw there’s a lot of code there

darwin00:01:20

it implements a mini-compiler for “selectors”, it tries to do as much as possible at compile time, but if it fails, it has a secondary code path which implements the same functionality at runtime

darwin00:01:35

plus diagnostics under dev mode, that adds a lot of complexity

darwin00:01:40

snippet #1 is understood at compile-time snippet #2 is dynamic

darwin00:01:26

validate_object_access_dynamically does checks that you do sane things

eyelidlessness00:01:06

i think i just realized what my particular issue is

darwin00:01:07

under advanced builds all diagnostics gets elided, closure compiler does its magic, in this case it elides most of the code: https://github.com/binaryage/cljs-oops/blob/master/test/transcripts/expected/oget_static_core.js

eyelidlessness00:01:15

i’m trying to use an arbitrary property with the html5 data api

darwin00:01:41

not sure what html5 data api is

darwin00:01:58

but if it is not covered by externs it will get munged

eyelidlessness00:01:05

e.g. <div data-foo=”bar”> and thatDiv.dataset.foo

darwin00:01:18

ah, I see now

darwin00:01:27

you need to use string names in this case

eyelidlessness00:01:39

yeah i just spotted it, and it made perfect sense.

cfleming00:01:43

For node.js CLJS projects, can I add test-only modules using lein-npm?

cfleming00:01:27

I see that I can put npm deps in the dev profile, but then they get installed under node_modules like everything else. How do I then stop them being included in deployment jars etc?

selfsame01:01:51

does lumo have 'spit' and 'slurp' or is that just a planck thing

darwin01:01:58

if it does not yet, you can implement your own using node.js apis: https://nodejs.org/api/fs.html

darwin01:01:27

I don’t follow lumo that closely, but I think it is planned to support std clojure functions

selfsame01:01:57

yeah guess that's best anyway

mfikes01:01:36

Right, @selfsame, you can use Node's I/O capabilities. In the future Planck and Lumo may both implement a common set of I/O interfaces so that code is portable.

mfikes01:01:10

If you want portability, I’d consider coding using spit and then referring it from some other namespace (your own impl if in Lumo, or Planck’s if in Planck)—that way you can muck with the ns as needed to port.

qqq01:01:43

foo.cljc defines a macro that foo.cljc also needs; is there a way to make this work when compiling in cljs mode, or is this .impossible?

selfsame01:01:52

@qqq looks like yes if you do a

(require '[foo :refer-macros [bar]])

selfsame02:01:05

from inside the foo ns

mfikes02:01:01

You can also take that stuff to an extreme with something like https://github.com/cgrand/macrovich

selfsame02:01:13

(defn spit [f s] (fs.writeFileSync f (prn-str s)))
(defn slurp [f] (.toString (fs.readFileSync f)))
good enough 🙂

mfikes02:01:09

Yes. IIRC Planck’s spit started off with something like that. No need for writer, IWriter and all of that machinery for most use cases.

mfikes02:01:29

Interesting use of prn-str there

mfikes02:01:08

Perhaps just str would more closely match Clojure’s spit.

selfsame02:01:52

yeah can't remember if i needed the prn-str

qqq02:01:51

@selfsame: that worked; thanks! apparently there's a recent patch where cljs looks at the require, figures out if it's only importikng macros, and if so, drops it to avlid circular dependency

futuro04:01:53

@mfikes I'm really interested in the idea of a shared protocol implementation for host specific things across different self hosted cljs implementations

futuro04:01:51

As I've been dissecting the nrepl code one of the barriers so far is how to right file reading/writing functions in a vm agnostic manner

futuro04:01:14

Another is how to handle socket reading/writing functions agnostically as well

mfikes04:01:36

Yeah, having an agreed upon “standard IO lib” would be great for portability.

futuro04:01:09

I've been thinking about how the different host maintainers could write these functions in such a way that a shared io lib wouldn't need vm specific code in it

futuro04:01:54

So far protocols are the thing that comes to mind, but I'm not sure I understand them well enough to vouch for their usefulness

futuro04:01:49

But if we could say (instance? cljs.io.Closeable obj) or some such, that seems ideal

futuro04:01:25

Then all that matters is that we can call close on the object

futuro04:01:51

(Or insert apropos method here)

mfikes04:01:26

Yeah, a standard lib would probably define functions (like spit) and protocols (like IWriter), etc., but somehow have hooks so that the guts of spit can be satisfied by any self-hosted environment.

selfsame04:01:40

@futuro funny was working on some clr/cljs stuff like that tonight https://github.com/selfsame/ip/blob/master/ip/impl.cljc

mfikes04:01:15

Yeah, the same sort of stuff is sitting in the mach codebase too 🙂

futuro04:01:02

@selfsame that's pretty neat. My current target is lumo, but I want this to easily extend to Planck and any other vm as well, so I've been trying to avoid thinking so hard about a node way of handling io

futuro04:01:48

I was reading through the Planck source earlier cause I wanted to see how you'd approached this issue already

futuro04:01:41

Ah, yeah, I suspect this has been solved a couple times over for specific hosts

mfikes04:01:15

I just imitated Clojure, especially its IOFactory framework, and at the bottom have a bunch of functions injected like PLANCK_LIST_FILES, PLANCK_FILE_READER_OPEN, etc.

futuro04:01:26

(Though I love how easy it is to pull in js deps!)

mfikes04:01:04

You could imagine a shared library that defines spit but expects a given environment to inject the actual low-level IO functions.

richiardiandrea04:01:27

@mfikes did not know about juxt/mach that's great thanks! I am happy to many self-hosted tools are popping up

richiardiandrea04:01:52

I opened the #cljs-node channel btw exactly for this 😁😁😁

futuro04:01:52

@mfikes when you say "inject" are you talking about the js/PLANCK_FILE_READ_OPEN calls?

mfikes04:01:54

Yeah. So, imagine a shared library that is not defined by Planck or Lumo, but is sort of a clean I/O layer that anyone could build code upon, but then different environments could inject the low level IO facilities that that library requires to be satisfied in order to actually function.

richiardiandrea04:01:05

There is even a (alpha) replacement for aether: https://github.com/eginez/huckleberry

mfikes04:01:56

By “inject” it could be that there could be a set of dynamic vars that different environments set! upon initialization.

fellshard04:01:25

So the question is - what are the core abstractions of a REPL?

mfikes04:01:51

(def ^:dynamic *write-content-to-file*)

(defn spit [f content] (*write-content-to-file* content f))
or somesuch

futuro04:01:53

That feels really brittle, or that it would require a lot of careful coordination

mfikes04:01:25

With Planck, I tried very hard to not invent anything new, but to copy and closely mimic what Clojure provides.

futuro04:01:07

@mfikes what about relying on the object that gets passed in to adhere to a set of protocols?

mfikes04:01:05

@futuro That would be ideal, but I suspect there are a lot of functions in Clojure that you want to imitate that wouldn’t work out easily with a pure protocol-based approach. Just a guess.

futuro04:01:35

Cool, I'll give that a ponder :)

mfikes04:01:46

@futuro Take, for example a challenging one like . I like the approach of having an imitation of the system built in ClojureScript, with native functions at the bottom where needed.

futuro05:01:12

So my thought is to have the host vm's extend the base protocols with their host specific implementations and have the rest of the functions that operate on those protocols

futuro05:01:21

Primarily it seems to be the cleanest way to have clean code, and I'm not really sure how we'd use dynamic vars like you mentioned before

futuro05:01:05

It seems like the kind of thing that would force you to embed code for each platform inside of the library

fellshard05:01:07

Think the hexagon arch, yes?

fellshard05:01:24

You'd have the core definitions in one lib, then adapters and implementations in others

futuro05:01:01

Yeah, exactly

mfikes05:01:38

@futuro That sounds cool tool. You’ll see what I meant by dynamic vars if you check out (doc *print-fn*)

futuro05:01:36

That's crazy, but neat

futuro05:01:47

Ok, time for bed

futuro05:01:02

Thanks all 😄

futuro05:01:03

@mfikes I'll check out the source for that var and see what they get up to

mfikes05:01:31

Yeah, it is one way of setting state (a function) for a lib to use.

pbaille09:01:59

hello, how can I create a regex from a str?

pbaille09:01:51

found it 're-pattern

conan14:01:19

anybody know how to get added to the list of companies using ClojureScript? http://clojurescript.org/community/companies

mpenet14:01:15

woa ebay uses clojurescript? anybody knows where?

mpenet14:01:34

on a dashboard thing apparently

selfsame16:01:16

do we have a standard for sniffing out if the host env is node-cljs/cljs?

dnolen16:01:23

@selfsame nope, whatever is done in JS is your best bet

Yehonathan Sharvit18:01:23

I don’t know why and when but sometimes I am losing the ability to set breakpoints in chrome for my code built with figwheel

Yehonathan Sharvit18:01:44

Does anybody know how to restore the breakpoint capabilities?

cfleming21:01:01

I’m using aws-sdk-js from cljsjs. When using node, I use (def AWS (nodejs/require “aws-sdk”)) - is (:require [cljsjs.aws-sdk-js]) required as well?

cfleming21:01:07

Or is that only required in the browser?

thegeez21:01:12

How do I get a nice page with the results from cljs.test cases? Preferably a page that reloads and reruns after file changes. I think I have seen this somewhere. I don't mean devcards

cfleming22:01:14

Actually, I just realised that for node, I don’t need cljsjs at all - never mind me.

notanon22:01:46

because you're going to install deps with npm? (via lein or boot presumably)

cfleming22:01:38

And I don’t care about advanced compilation.

notanon22:01:33

it's pretty nice that just about every js lib on earth is packaged up on npm for us, thanks js ecosystem, we'll just have that for free please.

notanon22:01:02

well obviously thanks to lein and boot for making it easy, putting it within reach of us mere mortals

hueyp23:01:10

anyone run into unicode getting like an “A” in front? I’m trying to render an arrow and use “\u00BB” but advanced compilation renders: “»"

hueyp23:01:10

I’m not 100% sure where it happens actually … local dev is fine, compiled is not, but it might be someplace else 😜

emccue23:01:42

Hmm, closure shouldn't change strings so Im not sure. Where do you use that in your code?

emccue23:01:23

And does anyone know a way to have everything under window.something be externed? Because that would be helpful

hueyp23:01:58

its just a pagination button 🙂

hueyp23:01:18

I should narrow down where it happens