near / wallet-selector

This is a wallet selector modal that allows users to interact with NEAR dApps with a selection of available wallets.
https://near.github.io/wallet-selector/
Apache License 2.0
151 stars 152 forks source link

Large bundle & other tech debt #1165

Open elliotBraem opened 2 months ago

elliotBraem commented 2 months ago

While investigating the large bundle size of another project, I noticed the size of near-wallet-selector took up a pretty hefty portion (60 KB gzip), despite only being a wallet-selector modal with separate, composable modules.

See version @near-wallet-selector/core#8.9.10 on Bundlephobia

In investigating this, I also found that v8.9.11 introduced double the size (122 KB gzip), seemingly because of a near-api-js upgrade/using many modules, @noble in account-export package, and what I'm assuming is poor code splitting.

Some things I've noticed:

And then some miscellaneous items

It seems to me like a lot of this is just tech debt that hasn't been addressed from 2 years ago after migrating to a monorepo (and that's okay :) ). Otherwise, I'd really like to learn more about why any of these choices were made, what changes should be implemented, and I'd like to help in any way I can, as well!

Hoping to start a conversation on some of these items -- I feel like the wallet selector is a cornerstone package for the ecosystem and should not bear so much weight on any application integrating it.

pivanov commented 2 months ago

I'm working on something to reduce the size ... excluding everything you mentioned and with which I agree we have few more things to mention ... we have a bg CSS file (~40KB) in modal-ui.

Here is a shot with the changes in next release the size is ~ because we are waiting few more things to be merged but still ;) ...

@near-wallet-selector/core (hopefully next release)

image

this will help for now ... but still ... there is more space for improvements :)