Fork me on GitHub
#clojurescript
<
2017-11-16
>
dominicm12:11:33

Is it possible to mark a js file as "do not optimize this at all" in clojurescript?

dominicm12:11:53

I want to include some js for side effects, I'm not interacting with the js at all.

thheller12:11:03

if it has no dependencies you can abuse :preamble

gfredericks14:11:27

Does (cljs.reader/read-string ":/") work on recent versions of cljs? Should it?

bronsa14:11:21

it does and it should

bronsa14:11:29

that's a valid keyword literal

bronsa14:11:52

just like / is a valid symbol

gfredericks14:11:53

Okay. I have an older version where it doesn't, so I'll figure out how to upgrade; thanks

grzm15:11:36

Clojurescript vs the Stacktraces: A Tragicomedy of Errors. (Or just a big misunderstanding?)

grzm15:11:47

I've recently taken a deep dive into trying to parse/map/return humane stacktraces in Clojurescript and have hit my head on the bottom of the pool.

juhoteperi15:11:14

@mark-i alias takes the both arguments as symbols: (alias 'extra 'hello-world.extra)

grzm15:11:20

By humane, I mean parsed stacktraces that return function/file/line/column for the original source files at runtime. It looks like the machinery is all there (mostly in cljs.stacktrace and cljs.source-map), but I can't figure out how to assemble it.

pesterhazy15:11:50

How about this syntax for JS object destructuring? https://gist.github.com/pesterhazy/42c94768ed3dd991ea83ae96b4a6f57e Any other ideas?

grzm15:11:40

The primary issue I see at this point is figuring out how to generate/get access to the sourcemaps, building up a structure that would be passed to cljs.stacktrace/mapped-line-column-col (https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/stacktrace.cljc#L564-L568)

grzm15:11:20

If anyone has a little experience with this, or is at least willing to talk some of it through with me, I'd appreciate it.

mark-i16:11:31

@juhoteperi thanks, I tried, but with same error. The alias call works in clj.

rauh17:11:52

@pesterhazy Destructing already has :keys, :some-ns/keys, :strs, :syms So if you want functionality for JS objects I'd add another keyword there instead of some other syntax

rauh17:11:16

FWIF, you can:

(extend-type default
  ILookup
  (-lookup [o k] (aget o k)))
(let [{:strs [a]} #js{:a 2}]
  a)
Not that I'd recommend doing that.

pesterhazy17:11:51

yeah I'm looking at a way that you'd actually want to use in projects, so extending protocols seems dangerous

pesterhazy17:11:47

@rauh, adding a new keyword may be a good idea, but to my mind those are all shortcuts for the long form, {binding key}

pesterhazy17:11:12

where key would be a key, string, sym etc

pesterhazy17:11:24

the other problem I see is that using a {} form implies (to me) that the value is a persistent map, not a js object

pesterhazy17:11:58

i.e. :keys, :strs etc modify the type of key, not the type of object you're dealing with

john19:11:24

What about just making it a js object? #js {background-color "backgroundColor", :keys [color]}

john19:11:51

People usually use {:keys [... though, and (let [{:js-keys [color]} ... would be more aesthetically pleasing I think.

john19:11:07

that would ambiguate the the long-form semantics though 😕

borkdude20:11:52

Is there a way in cljs that returns “PersistentSomethingMap” for (type m) instead of some function? I find it easier to debug that way

grav20:11:27

In both lumo and figwheel, I get cljs.core/PersistentArrayMap

borkdude21:11:12

@grav That’s cool, but when I do (debug (type m)) I don’t get that

borkdude21:11:23

I do get a readable format with the devtools thing

thheller21:11:26

(pr-str (type m))

pesterhazy21:11:48

@john92.walter, using #js would be the logical thing, I agree - but not sure if a macro can deal with a reader macro like that