Fork me on GitHub

can anyone point me at something that can be used in real-life project that would allow easily include any piece of javascript from npm? Maybe something that utilizes webpack? Basically what I’m struggling with is to take something like and be able to use it in Om-next project


@dnolen: not sure if you are aware of it, I'm was testing version 1.9.70 here and this is erroring: (inst? (js/Date.)) with #object[TypeError TypeError: Cannot read property 'call' of undefined]


same trying to (inst-ms (js/Date.)) or (satisfies? Inst (js/Date.))


sorry, my bad, forgot to restart my browser after updating the cljs, all working fine


Hey everyone. Just thought I'd drop a short note on strange behaviour in subvec. In clojure

(def foo (subvec nil 1))
CompilerException java.lang.IndexOutOfBoundsException, compiling:(form-init4645269128697935824.clj:1:10) 
(def foo (subvec nil nil))
CompilerException java.lang.NullPointerException, compiling:(form-init4645269128697935824.clj:1:10) 
In ClojureScript:
(def foo (subvec nil 1))
#object[Error Error: Index out of bounds]
   cljs.core/build-subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5316:16)
   Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$3 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5328:7)
   Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$2 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5326:7)
   cljs$core$subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5319:1)
=> nil
(def foo (subvec nil nil))
=> #'user/foo


And doing anything with foo afterwards fails:

#object[Error Error: No protocol method IIndexed.-nth defined for type null: ]
   cljs.core/missing-protocol (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:264:4)


I'm filtering a long list of numbers, and want to get rid of all NaN in there. The problem is that (= NaN NaN) => false. How can I test a JS/Clojurescript number to be a REAL number? (on a related note, Wat:


@metametadata: thanks! You're so right. (I'd like some curry with that... Sorry, it had to be done)


@alfkristian: looks like a minor bug, feel free to file that in JIRA


I'm using Leaflet.js (javascript library to be able to pan and zoom geographical maps) and getting this error: main.js:1977 Uncaught TypeError: is not a function, but only with :optimizations :advanced. With the error you can't see the map at all. It worked fine with :whitespace. I know the source code that is at fault, but I don't know the reason for the error. Has anyone seen this before?


@cjmurphy: advanced optimizations munges names


for JS that doesn’t go through the Closure pipeline (random 3rd party JS library) you need to provide externs


@cjmurphy: are you using the CLJSJS version of leaflet?


No - just copied from rete4flights. Looking at blade now. Will look at CLJSJS too thanks.


yeah if you don’t want to supply your own externs I would look for a CLJSJS versions of the lib you want to use


Btw. regarding the need for externs, has anyone tested what size and performance benefits does using form for JS calls and properties have? Scala.js uses foo["bar"] form which means they don't need externs (it is not perfect solution either:


@juhoteperi: not aware that anyone has, would be interesting to see that in large projects - also the auto-generating externs idea is still sitting around for someone to tackle


Sure, it would be possible to automatically generate externs in Cljsjs tooling or Cljs compiler, but the approach of evaluating the code and inspecting the object doesn't work on ~10% of libs


So I'm not sure that is the best solution


One solution would be to use Fence, or something similar:


Fence readme also says that foo["bar"] will be optimized to, so there won't be size differencen for external calls


So the real problem is to differentiate calls to Closure libs (which need to be mangled) and foreign libs


Don't we use externs, so we can rename/get rid of, parts of libraries? Wouldn't we lose that by doing ["bar"]?


Dead code elimination doesn't work with foreign libs, externs don't affect that


Oh, I thought it did. Makes sense then.


Clojure: (clojure.string/split "qwe" #"") ; => ["q" "w" "e"] . ClojureScript: (clojure.string/split "qwe" #"") ; => ["" "q" "w" "e"] , note new first element empty string. found this to be happening on Java 7 but fixed in Java 8 and was thus closed—but it remained a Clojure-only issue, no mention of ClojureScript. I'm also looking at and where specific divergences between Clojure/Script split are being fixed. Should I try to reopen 1312 because the difference exists between clj/cljs, or open a new ticket, or any other advice?


@fasiha: the advice would be to determine what the source of the divergence actually is


if we’re bottoming out in JavaScript behavior we’re not going to do anything about it


@dnolen: that makes sense. No, JavaScript does the right thing: "qwe".split("") // => ["q", "w", "e"]. Maybe some code in ClojureScript that was added to synchronize clj & cljs behavior may be inadvertently introducing the empty string. Will look.


@fasiha: great, thanks for looking into it


includes all the latest relevant changes in Clojure 1.9.0-alpha7