-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web3.js: library is not tree-shakeable #1122
Comments
I started work on this, this week. |
OK, but don't get too excited. :) |
Alright, I did a ton of hacking and slashing. You can take a look at a draft of this work in solana-labs/solana#25014. But probably don't. But if you do, I welcome your feedback. There are two main obstacles that an optimizing compiler faces when trying to tree-shake our JavaScript SDK.
I'm going to have a think about what I've done so far, and come back to it next week with fresh eyes. I think it's close. |
Hello frens. I have not forgotten about this. Now that my head is slightly above water, having shipped the first version of the mobile phone JavaScript SDK, I can turn some attention back to stuff like this. |
any updates on this? i am trying to bundle a package that has solana web3 as a dependency with rollup and i keep jumping from one error to another. |
The tack I'm taking at the moment is to rewrite web3.js entirely, with tree-shakeability as a core tenet. You can follow along as I build it up, piece by piece, https://github.com/solana-labs/solana-web3.js/tree/master/packages/library. |
Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up. |
Problem
@solana/web3.js
is not tree-shakeable.I've created an example repo with a short README demonstrating this issue. To summarise it very briefly...
Currently bundlers such as webpack and rollup cannot extract specific sections of code from web3.js, including the .esm.js build. This means that any project that using it will either be including the entire library or at least a significant portion of it.
Some of the issues I think this raises -
Proposed Solution
Perhaps the esm build could be produced by typescript's
tsc
and then be verified to be tree-shakeable with something like agadoo as an extra CI step before publishing. I did make a quick attempt at this but it looks like it's going to need more work than just building with tsc.The recommended steps by Rich Harris (rollup creator) in the Agadoo README are -
The text was updated successfully, but these errors were encountered: