swannodette / mori

ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript

Home Page:http://swannodette.github.io/mori

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advanced compilation removes cljs$lang$type, needed for cljs-devtools

darwin opened this issue · comments

I wanted to add a new module mori.devtools.js, which would provide optional cljs-devtools support for mori users.

This should be easily doable without cljs-devtools modification, because mori is a subset of cljs.core.

Unfortunately advanced compilation removes cljs$lang$type properties on types which cripples cljs-devtools ability to detect cljs values.


A side note:
removing cljs$lang$type is IMHO incorrect because I can see that some emitted code tries to test for its presence. This points to more general problem of some unintentional code removal in advanced mode.

Steps to reproduce:

  1. change "release" build config to:

    :pseudo-names true
    :pretty-print true

  2. lein cljsbuild once release

  3. open ./release/build/mori.base.js and search for cljs$lang$type, there are some usages, but no places where cljs$lang$type is set on prototypes.

Easy enough to add that property to the externs.

Ok I will study more about externs.

I would suggest introducing a new exported function into clojurescript core which would do cljs$lang$type check, add it into clojurescript tests. This way I believe cljs-devtools could use it safely even under advanced optimizations.

@darwin there is no corresponding predicate in Clojure and I'm not convinced it's a good idea to expose such a thing to normal ClojureScript users. Tools can tap into this implementation detail for the foreseeable future.

The problem is more complicated and needs intervention on clojurescript side (I think). I had to open a ticket:
http://dev.clojure.org/jira/browse/CLJS-1249

btw. now I'm finally able to attach a debugger to java/clojure/clojurescript compiler and see better what is going on. Another step to be more helpful with future fixes/improvements :)