mori icon indicating copy to clipboard operation
mori copied to clipboard

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

Open darwin opened this issue 9 years ago • 4 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.

darwin avatar Apr 26 '15 19:04 darwin

Easy enough to add that property to the externs.

swannodette avatar May 04 '15 13:05 swannodette

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 avatar May 04 '15 13:05 darwin

@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.

swannodette avatar May 04 '15 13:05 swannodette

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 :)

darwin avatar May 06 '15 05:05 darwin