-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
v2.0 big bundle size #259
Comments
Hi, @fraserxu, thanks for the question and bringing my attention to it. Yes, it became bigger since I drastically rewrote the structure of the project. However, it may contain something that might be not useful for everyone, but for some, like the |
I just had a build locally and get the following result:
So I believe To avoid pushing docs to npm, you can add In this repo, maybe just |
I also am concerned with the dramatic increase in bundle size, @fraserxu if I understand you correctly the size reported by bundlephobia is off because the author is publishing extra stuff and a webpack build will ignore all that? |
I guess, we have to take a more precise look at the output of the build, so there might be some extra-scripts included by webpack into the final build of the main files (es5.js, bundled.js). I just don't have enough time to take care of this. If you guys have time and would like to participate, please, you're always welcome. I really appreciate any help with the package. Just ping me if you find any redundant code in the final build and we could investigate where it comes from and how we could get rid of one to make the bundle less 🙏 |
My only reason to use bowser is to get info about the browser. I would love to be able to write something like import parse from 'bowser/parse'
parse(window.navigator.userAgent) to avoid loading the whole bundle. |
Count me as another person who has to downgrade due to bundle size. After upgrading to v2 my components bundle size increased by 16.56 kB. Looking at the code for bowser@v2 it seem like it will be quite the challenge to get it back down at all. The code is about 2000 lines long and it seems like almost all of it is used during a run of any of the functions. |
Hi, @hipstersmoothie and all! I have good news. I tried to dig into the issue. First thought was to ensure that all the modules are legit and there's nothing extra taking into the build. I used Then, with the next step, I researched the build itself and its expressions. In a few minutes, I've figured out, that we were having not the most optimized settings for Babel. So, I experimented with changing the modules system it uses in the build (changed Thus, I managed to reduce the build size by 20% from the latest build (2.5.0) — But, the main reason for the problem is that the 2.x version brings a lot of new functionality and API, which makes bowser better and more convenient, but also a heavier tool. There always will be two different groups of users — the ones who concerned with the bundle size and the others who interested in rich API and more features from the box. Nowadays, the 2.x is something in between for those two groups — it does its thing good and has some fancy API for itself. But, I think, we could think of having some modular system that would make it possible to avoid useless functionality in the build easily. It would require some refactoring and solid architectural approach, and quite some time, but it’s doable. I'm not sure if I will be able to develop it on my own this year, but, let's see. One more point here:
No, it's not. Bowser's And thanks for your message. It's essential for me to know what exactly matters for the users. |
@lancedikson thanks for the work here to reduce the bundle size. I would add that if the imports are tree-shakeable then even if the bundle size is larger, people will only be adding to their bundle the bits that they are actually using. E.g. if you could somehow |
Right, good point, @audiolion. I will try to look at the current module's structure from that perspective first. Maybe a little refactoring would solve the problem for most of the library users. |
Trying to use this package in our project, but after checking the bundle size with
bundlephobia
, the new v2 bundle is almost 3 times the total size of v1.https://bundlephobia.com/[email protected]
Maybe there's some issue with the build script?
Upvote & Fund
The text was updated successfully, but these errors were encountered: