Fork me on GitHub
#cljs-dev
<
2021-01-14
>
kommen09:01:29

we’re running into an edge case regarding how the cljs compiler indexes node modules: https://clojure.atlassian.net/browse/CLJS-3293

kommen09:01:00

would a patch which adds support for .cjs as main files in package.json like this be acceptable? https://github.com/nextjournal/clojurescript/commit/f48609b862062caae6d19d5d281c4f7b53a39c25

dnolen17:01:41

sure thing

dnolen17:01:42

@borkdude there are performance implications for that

dnolen17:01:25

Clojure has class but that doesn't make sense for JavaScript

dnolen17:01:32

so I just used type

dnolen17:01:45

originally this wasn't done for anything related to Clojure reallly

dnolen17:01:01

type was missing and needed for fast membership testing

dnolen17:01:51

you can't really just invoke -meta on anything, you will fall into a slow path

dnolen17:01:02

at least when I looked ago not very optimizable

dnolen17:01:16

so code that would be fast will be punished for things that don't match

dnolen17:01:44

all that said, the issues could be separated

borkdude17:01:58

@dnolen true, checking :meta is an extra step - is type a thing that is used in hot-loops though? Could be. Does CLJS use type internally for protocols/multimethods? It's not a big problem for me. I hit this issue in sci (Clojure interpreter) because I am using :type on its implementation of records (which are just there for compatibility).

dnolen17:01:04

there could be a new thing that does what type used to do, and type could do Clojure behavior

dnolen17:01:26

would need a lot of lead time on this because it would be seriously breaking behavior now

dnolen17:01:36

so ten years of not following Clojure here might be too much water under the bridge

borkdude17:01:29

I suspect many people aren't even aware of type + :type metadata on the JVM

dnolen17:01:40

and it's not often requested

borkdude17:01:16

So the way it works in sci now is that (= (type x) (type y)) returns true if two things are of the same record type, which I think is better than relying on the concrete return value of type. Although it was also requested to get back the namespace and name of the record type. I wonder if that is possible in CLJS at all.

dnolen17:01:14

name is already there

dnolen17:01:19

needed for printing

dnolen17:01:30

and it's fully qualified

dnolen17:01:45

it's a manually mangled property but we're not going to change it