Ideas: more attributes to tweak the record layout

I think this the best design. Minification would be useful, but the @minify attribute seems like it would create confusion.

How about a more explicit attribute, like @nominify? “Strict” can have ambiguous meanings.

Both terser and closure compiler can do this.
I know rescript can do that safer/better but i don’t think saving some bytes would be that important.
tree shaking/removing dead code and general minifcations done by js minifiers combined with compression in asset delivery is enough for everyone.

5 Likes

I didn’t think Terser did, but then I looked it up and you’re correct. However, it does have this warning:

Note: THIS WILL BREAK YOUR CODE. A good rule of thumb is not to use this unless you know exactly what you’re doing and how this works and read this section until the end.

Considering that ReScript records aren’t as complex as most JS objects, I wonder if ReScript is safer to use with this option?

You get the point.

For most minifiers, their property mangling is incorrect and in-efficient, while our type based minifier is correct and more efficient.

The correctness is guaranteed by the type system.

Why it is more efficient?

Since it is type based, so you can map both field1 and field2 to a, if they are of different types. I proposed this since this is something we can do far better than the existing alternatives