-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Compiled web3 bundle is HUGE #1178
Comments
... It also includes 2 copies of bn.js for some reason |
Yeah, this is ridiculous. I'm preparing what is basically a static site and this is hugely problematic for many people worldwide that attempt access. |
|
The next step would be to move to es6-modules so we do not require the whole |
Yes we have an 1.0ES6 branch @pubkey please feel free to contribute. |
@nivida Is there a status page or something summarizing the current status of the ES6 branch? I can contribute, but don't really know where to start or what has been done so far. Maybe a Github Project tracking it would be helpful. |
+1 to this issue. Final size of my bundle instantly bloated from 240kb to more than 1mb just by importing web3, analyzer stats are similar to @pubkey - six imports of bn.js. This is absolutely unacceptable, is there any workaround for this issue? I am using beta 35. |
Hay all, I'm tested it with severall webpack configs for optimizing the package dependencies and I also checked the BN.js versions but with no success. The problem is that we have X package.json files for each web3 package this gives us the possibility to publish each package as standalone package on NPM but on the other hand it blows up the dependency graph. My current workarround would be to include the minified version of web3 directly from the node_modules dist folder this file is only ~700KB. I'll talk about this with fabian maybe we could change the project structure. |
I think it would be better to switch to a mono-package instead of publishing |
@pubkey I agree with this. Is there any progress on this issue? I am willing to help. |
If you reference a version range in package.json, npm can reuse the same |
What's the current status of this? The bundle size is continuing to grow. beta36 added almost 200KB minified to the bundle size. At this point we are punting upgrading because of the extra bloat. beta36 - 791.88 KB I think your comment on Aug 20 is the correct way to solve the BN.js duplication issue. Maybe that can be done for just the purposes of building the |
@pubkey @nivida running
So we should ask these packages to loosen their dependency to |
Different but related thing I would like to ponder about is how to make the So package.json could look like this:
web3-slim is the module that will assure the same usage of |
@josephg yes, asking them to loosen their bn.js version would be a great improvement. |
can use webpack alias to solve this issue.
module.exports = {
// other configs
resolve:{
// other configs
alias:{
"bn.js":"fork-bn.js"
}
}
} There is only one |
I've created a webpack example here and I think this is a good boilerplate to start. The long term goal will be to refactor the folder and module structure for preventing the multiple bundling of dependencies. |
@nivida you list a better option |
Not stale |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
not stale |
Still not stale, package is quite large. |
not stale |
1 similar comment
not stale |
Is there really no way to reduce the load this takes on a bundled app ? Is there no way to defer loading this package only when user interacts with a button that would require functionality from this ? |
I think analyzers are watching "the whole picture", so that could be the reason you can see it, but this is really an analyzer issue. Same with deferring package loading, that should be solved by next/your app. The issue with the lib is its non-treeshakeable nature. It should be rewritten using ES6 modules. |
+1'ing here. |
Seems like a perfect job for a gitcoin grant |
I think most people rather use gitcoin to throw a 5 years party of this issue this year and hire the best djs ! Clearly nobody cares about 800kb download. |
1.x is in min required maintenance phase and optimizations candidate is web3.js 4.x , we recently released |
https://bundlephobia.com/package/[email protected] it's dropped to 1.1MB minified and 310kb gzipped from 2MB minified, 640kb gzipped |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Not stale 🙃 |
At this point, maybe we should make a POAP for those of us still tracking this. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Not stale |
Not stale |
1 similar comment
Not stale |
closing this issue in favor of 4.x release All further optimizations will be done in 4.x only and 1.x will be in minimum maintenance phase. |
The browserify-compiled web3 bundle is crazy huge. I'm using the 1.0 beta and pre-minification web3 is 1.3 megs. Minification halves that, but its still way bigger than it needs to be.
Most of the bundle is transitive dependancies of dubious usefulness that the dapp I'm writing certainly won't need - like an ASN1 parser, an elliptic curve cyper, a 160k promise wrapper (wat) and the distributed filesystem libraries.
Have a browse of the contents of the compiled bundle.
Fixing this will not just lower download size, it will also make dapps load faster and improve the experience from nodejs. Node currently needs nearly 1 second to parse all that JS even on my fancy macbook:
The text was updated successfully, but these errors were encountered: