Fork me on GitHub
#shadow-cljs
<
2018-09-10
>
heyarne11:09:11

I'm trying to play around with http://ptsjs.org/, which can be installed with npm i pts. Doing a naive (:require ["pts" :refer Pt]) gives me the following error:

--- node_modules/pts/dist/index.js:3828
This code cannot be converted from ES6. extending native class: Float32Array
--- node_modules/pts/dist/index.js:4022
This code cannot be converted from ES6. extending native class: Array
How do I approach this? There's a minified version in dst that contains different non-convertible es6-code and an es5-version that's follows UMD from what I can see. Trying to require the es5-version gives me No such namespace: Pt, could not locate Pt.cljs, Pt.cljc, or JavaScript source providing "Pt".

thheller12:09:14

@arne-clojurians you can probably set :js-options {:language-out :ecmascript6} in your build config

heyarne13:09:42

now i'm slightly confused... there's a shadow.js.babel in the shadow global variable? i skimmed the docs and it said something about running babel yourself for things like jsx interop, but there's a bundled babel as well?

lilactown14:09:10

@arne-clojurians I ran into this a little while ago. I posted an issue here: https://github.com/williamngan/pts/issues/22

heyarne15:09:20

did you try to bundle your code with advanced optimizations? basically as soon as i do (.. form (stroke "#abc") (fill "#def")) it tries to optimize to heavily. even if i type-hint form it can't infer the call to stroke and won't know what it returns, causing it to not find fill which has been obfuscated

heyarne15:09:23

so what i do now is (.. form ^js (stroke "#abc") ^js (fill "#def"))... but this doesn't feel like a sensible thing to do

heyarne15:09:09

maybe @U05224H0W knows something about this, is this a problem of closure compiler and chaining APIs?

lilactown15:09:36

do you have infer-externs on?

heyarne15:09:43

i guess it's on :auto by default?

heyarne15:09:28

(-> ^js form (.stroke "#abc") (.fill "#def") (.point whatever)) seems to work

lilactown15:09:38

it looks like I do have to annotate the space

thheller16:09:05

@arne-clojurians it is not on auto by default. you must turn it on. I think .. has a bug in that it doesn't propagate typehints properly

thheller16:09:24

-> is fine so use that

lilactown14:09:42

thheller’s solution is what I used

👍 4
thheller14:09:50

@arne-clojurians the built-in babel is used to transform ES6 code from node_modules only.

thheller14:09:13

only using babel because of some compatibility issues with closure