#community-help

Reducing Bundle Size of Typesense-instantsearch-adapter

TLDR David raised concern about the large size of the typesense-instantsearch-adapter. Jason suggested enabling tree shaking to reduce the size and also recommended using an existing axios installation.

Powered by Struct AI

1

Oct 24, 2022 (12 months ago)
David
Photo of md5-07c4f1bfa85fc4a2759ba7302f0b86da
David
11:03 AM
Other than not using instantsearch.js, is there a way to reduce the bundled size of the typesense-instantsearch-adapter? the adapter itself is ~4 times larger than the actual instantsearch.js library
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:59 PM
Hmm I see keys, synonyms, etc under the adapter, which technically shouldn’t be there when using the search client instead of client. Somehow tree shaking is not working…

May I know what you used to generate this graphic? I can take a closer look
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:00 PM
Cool thank you, will take a look

1

09:28
Jason
09:28 PM
Ah, I see what’s happening. The webpack-bundle-analyzer is analyzing the full contents of your node_modules folder, which by definition doesn’t use tree shaking.

Could you try turning on tree shaking in your webpack config, and then analyze the JS bundle file produced by webpack?

Separately, in your graph above, you want to include the contents of both algoliasearch-helper and instantsearch for comparison.

I also see that you already have axios installed, so I’m wondering if there’s some webpack config you could turn that just uses that axios instead of the one that’s mentioned in the typesense-js as a depenedency. That should reduce bundle size even further