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
Dist scripts are really heavyweight #123
Comments
The distribution build is definitely wrong. It includes https://github.com/HubSpot/tether and https://github.com/lodash/lodash. Shouldn't be a problem if you are using Webpack and Dedupe Plugin, but it can be annoying. One could either:
|
Ah, yeah that's related to #122. I was thinking about what dependencies should be peer/external dependencies and which one should be like the normal dependencies. Any thoughts? |
I think lodash and moment could be good peer dependencies. And there could be multiple distribution bundles. As I said, Webpack users shouldn't have big problems, but not everyone uses it. One thing that can reduce the bundle size a lot is requiring specific lodash modules instead of the whole library. Example: import sortBy from 'lodash/collection/sortBy';
sortBy([...], 'fieldA'); The same can be done with moment, so, even if the developers don't have these dependencies already installed, using react-datepicker wouldn't add up much to their final build. |
Oh, sorry. It's actually not possible yet to import moment modules like that. There's an issue (moment/moment#2373) regarding it. |
On a separate, somewhat related note: I'm also going to remove the example from this repository and instead turn it into a github page, this aught to clean up the PRs a lot. |
A little more info on what I did to make the file smaller: in |
Hi @RSO, Great news you made the datepicker so lightweight! As for what to put in the build, it is complicated to decide what to leave out. In your case I think it should be a great idea to leave react-onclickoutside and Tether. There is a big chance that the datepicker is the only lib that use them and they are not big enough to be a problem if they are repeated. In the timepicker put react-clickoutside and object-assign inside the bundle. Cheers |
@arqex 👍 |
The scary part here really is that H1 uses underscore in it's codebase :) let's hope that we don't use any lodash-specific methods in the datepicker ;-) |
How can the singleton scripts in the
/dist
folder be so big?https://github.com/Hacker0x01/react-datepicker/blob/master/dist/react-datepicker.js is almost 500KB.
The text was updated successfully, but these errors were encountered: