zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

[Feature Request] Remove `decimal.js`

Open genu opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. decimal.js adds an extra 31.9k of overhead to the bundle.

Its quite a heavy dependency considering that we're using just a few methods from it, like isDecimal()

Describe the solution you'd like

  • Is it possible to just implement the features we need from decimal.js directly?
  • OR using lightweight options like decimal.js-light or big.js

Describe alternatives you've considered I prefer removing the dependency altogether if possible.

genu avatar Jul 09 '24 18:07 genu

Just piping in here as a co-champion of the decimal proposal to mention a third option that currently doesn't exist but may in the near-ish future: having decimal numbers available out-of-the-box in JS, so that, for many use cases, no library is needed at all. Any comments, concerns, or questions are welcome! Just file an issue in the proposal-decimal repo.

jessealama avatar Jul 15 '24 14:07 jessealama

Is your feature request related to a problem? Please describe. decimal.js adds an extra 31.9k of overhead to the bundle.

Its quite a heavy dependency considering that we're using just a few methods from it, like isDecimal()

Describe the solution you'd like

  • Is it possible to just implement the features we need from decimal.js directly?
  • OR using lightweight options like decimal.js-light or big.js

Describe alternatives you've considered I prefer removing the dependency altogether if possible.

Hi @genu , thanks for filing this. Decimals are serialized as string over the wire and deserialized into Decimal of "decimal.js". I think it's good to preserve a decimal-like interface on the client side. If we completely get rid of the package, we'll need to implement such an interface.

I'm replacing it with "decimal.js-light" for now and it seems to work well (at the cost of not providing as many APIs). In the future if Decimal type becomes native, life will be much easier.

ymc9 avatar Aug 30 '24 05:08 ymc9

Fixed in 2.5.0

ymc9 avatar Sep 07 '24 16:09 ymc9