Skip to content
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

Are multiple packages still needed? #2109

Closed
alcuadrado opened this issue Dec 8, 2018 · 6 comments
Closed

Are multiple packages still needed? #2109

alcuadrado opened this issue Dec 8, 2018 · 6 comments
Labels
2.x 2.0 related issues Discussion Enhancement Includes improvements or optimizations Stale Has not received enough activity

Comments

@alcuadrado
Copy link

alcuadrado commented Dec 8, 2018

I'm getting up to date with the recent changes to this project, and read in @nivida's post that there will be different bundles of web3.js for different use-cases. This gave me some ideas that I'm sharing here.

My understanding is that web3 was modularized in many packages so users could pick the parts they need and avoid importing the entire lib, as it's really big. While node users also benefit from smaller packages, they are specially important for web development, and there's lots of tooling focused on that that could be leveraged.

Exporting an ESM-based version of web3 let users take advantage of bundlers' tree-shaking capabilities, resulting in small bundles (probably smaller than the current module-specific ones) without having to manage nor think about multiple packages. This may require some changes, but would also simplify the project, which could be once again a single package.

Note that this approach is becoming fairly standard in web development, and many of the most used libraries are adopting it. Some examples are: lodash, underscore and date-fns.

I haven't spent much time thinking about how big of a change this would be, or how much impact it would have on current users of the beta versions, but a quick look at web3 and web3-eth on npm reveals that the intermediate packages have very few direct users.

@nivida
Copy link
Contributor

nivida commented Dec 11, 2018

Currently, most are using the web3.min.js file or they are bundling the dapp with webpack and the web3.js bundle will go up to 6.2Mb.
The next release should not have a minified web3 file where anything is included it will just have UMD, commonJS and ESM bundles for each package. It has to be disscused with @frozeman .

I think the described coming changes above will be the first step to a new structure of web3 but our focus is currently on the stability and maintainability of the code. All bigger changes of this lib will be after the stable release.

This doesn't mean that I agree with you.
I thought for example about a repository structure without seperate packages on npm like this:

core/
    methods
    subscriptions
    providers
    modules
    ...
eth/
   abi
   contract
   ...

But all changes like this have to be done after the stable release and also to be discussed with @frozeman. :-)

@nivida nivida added Enhancement Includes improvements or optimizations Discussion labels Dec 11, 2018
@alcuadrado
Copy link
Author

Hi @nivida, I understand that the focus is currently somewhere else, and I agree with that. I just wanted to initiate this discussion before 1.0.0 is released because a change in the direction I described is somewhat in conflict with releasing stable individual packages. Maintaining the single-package and individual-packages versions at the same time would be a lot of work.

@levino
Copy link
Contributor

levino commented Apr 15, 2019

So the idea is to go back to from lerna monorepo with multiple packages to one package? I think one should create a new issue stating this Todo in a clear manner with a QA section and then reference this new issue here and close this one here.

I find that the lerna monorepo is not a good solution, only one package should be release (web3). I also would say that this issue should have the highest priority of all issues.

@levino
Copy link
Contributor

levino commented Apr 16, 2019

Not important for 1.0. Too much work.

@nivida
Copy link
Contributor

nivida commented Apr 16, 2019

I think if we do this after the stable release then we could combine it with my namespace idea which will improve the bundle size and will also give us some better ways to handle different providers with one web3 instance.

Namespace idea: https://gist.github.com/nivida/c7c24723353c243e295dbff954d06b50

nivida pushed a commit that referenced this issue May 15, 2019
@nivida nivida added the 2.x 2.0 related issues label Jun 20, 2019
@github-actions
Copy link

github-actions bot commented Jul 4, 2020

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

@github-actions github-actions bot added the Stale Has not received enough activity label Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x 2.0 related issues Discussion Enhancement Includes improvements or optimizations Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

3 participants