harmony-one / sdk

Javascript SDK of Harmony protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove encoding library bloat in @hamony-js/staking JavaScript SDK

klngrs opened this issue · comments

commented

When analyzing a recent build, I noticed that @harmony-js/staking is causing my bundle size to blow up due to the use of "text-encoding", which is now a deprecated library.

image

Reference:

import { TextEncoder } from 'text-encoding';

  1. I searched @harmony-js and it appears this library is only used in the staking sdk: https://github.com/harmony-one/sdk/search?q=%22text-encoding%22
  2. It looks like harmony is only using the UTF-8 encoder, since that's the default if no params are passed.
    https://github.com/harmony-one/sdk/blob/master/packages/harmony-staking/src/stakingTransaction.ts#L324

Given the above, I'd like to propose a leaner / tree-shakeable alternative to the deprecated "text-encoding"

Came here to say exactly this. TextEncoder has native support a long time already and text-encoding was deprecated three years ago 😃

40% https://bundlephobia.com/package/@harmony-js/staking@0.1.56

image

@gupadhyaya @Renewwen @denniswon could you please look into this? Thank you!