-
Notifications
You must be signed in to change notification settings - Fork 46
Why is this module so big? #617
Comments
Hey @joker-777, this is something we are aware of, a big reason this is a big module is because it's using lodash. It's not quite straightforward to simply undo that usage because most methods we are using accept both arrays and objects, so it's a not insignificant amount of work. Secondly part of this is because of older parts of the API that are now handled by React InstantSearch (e.g. URL Sync) are in here, and can't be simply removed without a major version. Unfortunately I don't have much more answer for you now, but we will work on this to make the module smaller in the future. If you're seeing obvious things that can shrink the code without too much work we can do those suggestions or merge those PRs before doing a significant effort too. |
Thanks so much for answering. I'm happy that you are aware of it and are trying to reduce it in the future. |
Yes, the version of lodash used is the subset of the methods we use (but it's still big because we use a lot of the methods). There's definitely some things that can be improved on this on shorter term, but I haven't yet been able to fit it in my plans |
Some sizes I have computed to see what is the biggest wins (everything I can think of is breaking change though, but stuff not used in our libraries)
|
Just want to also confirm, that InstantSearch javascript is way to big: |
Thanks for crossposting here @staabm, the main reason is indeed here too. One way to already get a smaller size, is by using code splitting (using a build tool, and importing only the used parts of InstantSearch). Updating to InstantSearch v3 (you're on v1) also will save about 30% already. |
oh thats interessting. do I need to handle any BC breaks between v1 and v3, or can I just transparently update it? Thank you! |
There's a migration guide from v1 to v2 and from v2 to v3 here: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/ There's definitely some breaking changes, but mostly naming changes and changed DOM to be more consistent |
Recent quick experiment I did for changing the event emitter. util + events → mitt. It's not entirely straightforward; see developit/mitt#90. Maybe a different one has less changes to the node events package). The impact is 35.3 kB → 31.3 kB |
This is fixed in v3 (yay finally!) You can already use the canary versions. I'll close this issue since our work on it is done, we went from: 97kb / 30kb gz to 42kb / 10kb gz https://bundlephobia.com/result?p=algoliasearch-helper@0.0.0-27095c0 Over time we hope to still decrease it by removing unneeded methods, but no major changes will happen further (ie we won't rewrite it fully) |
I juse
react-instantsearch
which includes this module. In the webpack analyzer I can see thatalgoliasearch-helper
needs quite some space. Why?The text was updated successfully, but these errors were encountered: