Fork me on GitHub
#clojurescript
<
2023-03-03
>
lilactown20:03:17

do record properties get renamed when optimized?

p-himik20:03:43

A quick test shows that yes, they do.

lilactown20:03:46

thanks, I'm still waiting on my release build to test clojure-spin

p-himik20:03:22

:D I have some tiny projects for such things.

lilactown20:03:24

I wish I could opt out... I actually find it useful to have a map-like thing that also has the same JS properties as keys

💡 2
p-himik20:03:57

If it's acceptable, should be somewhat easy to write a function that wraps an instance of a particular record in an object that lets you do that via descriptors.

p-himik20:03:26

But also feels like it's a reasonable feature request to have e.g. something like (defrecord R [^:export field]) supported.

p-himik20:03:40

(Which it isn't now - I just checked.)

lilactown20:03:05

I don't need the map functionality in reality, just made testing easier

lilactown20:03:41

I could hand a JS lib the result of (->Thing foo bar baz) and in my tests assert that :foo and :baz are right given some operation

p-himik20:03:32

Not sure I follow. Where does JS come in? Do you test your CLJS code with some JS library, by writing assertions in JS?

lilactown20:03:51

two use cases 1. I am passing objects to a JS library that need to look like #js {:foo ,,, :bar ,,,} 2. I want to write tests on functions that generate large sequences of these objects

lilactown20:03:13

my CLJS tests could access the record using (:foo thing) instead of (.-foo thing) is all

p-himik20:03:57

Ah, so the actual need is reversed. cljs-bean could help, but it would still be that wrapper.

thheller22:03:06

use externs

lilactown01:03:24

@U05224H0W you mean I'd add externs for my record?

thheller06:03:00

just

fieldA
fieldB
fieldC
and they won't get renamed