question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App Build size big due to export strategy.

See original GitHub issue

Hello,

I built my app with tree shaking using webpack 1 and I have some concerns over my build size as react instantsearch has a major chunk of it, if I combine it with algoliasearch and algoliasearch-helper.

The usual way to import is like this.

import {SearchBox} from 'react-instantsearch/dom';

This import tries to import everything that is exported from https://github.com/algolia/instantsearch.js/blob/v2/packages/react-instantsearch/dom.js

The impact of it is https://cl.ly/132r0M3H2l1n

56 KB which could have been 4KB

I changed my code from

import { InstantSearch, SearchBox } from 'react-instantsearch/dom';
import { connectInfiniteHits } from 'react-instantsearch/connectors';
import createInstantSearch from 'react-instantsearch/src/core/createInstantSearch';
import algoliasearch from 'algoliasearch';

const InstantSearch = createInstantSearch(algoliasearch, {
    Root: 'div',
    props: { className: 'ais-InstantSearch__root' },
});
import SearchBox from 'react-instantsearch/src/widgets/SearchBox.js';
import connectInfiniteHits from 'react-instantsearch/src/connectors/connectInfiniteHits.js';

and the impact was reduction of size from 113KB to 34KB.

The difference is 3x.

For someone who really needs speed in the app, every KB matters and tree shaking is not able to fix this.

It would be great if the export strategy is changed and this would help hugely with the user’s build size.

You can check the export strategy of material-ui here in case that helps. https://github.com/callemall/material-ui/tree/master/src

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanTheAllmightycommented, Mar 16, 2017

Doing what was suggested by @harshmaur cut my app size in half (250kb).

I think this is definitely something that needs to be addressed

1reaction
vvocommented, Mar 27, 2017

~That’s awesome, let’s do that! I can handle this, I love build tools~

EDIT: I did not handle it, do it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Verify App Build size big due to export strategy and add ...
The goal here is to create a new application using React InstantSearch and very if the build contains only imported functions.
Read more >
Reducing your app's size | Apple Developer Documentation
To create an app size report: Archive your app in Xcode. Export your archived app as an Ad Hoc, Development, or Enterprise build....
Read more >
Reduce your app size - Android Developers
This page describes how to reduce your app's download size, which enables more ... Although Android supports all these densities, you don't need...
Read more >
Measuring your app's size - Flutter documentation
The app size of a debug build is large due to the debugging overhead that allows for hot reload and source-level debugging.
Read more >
The Apk file exported from Android Studio is too large
The difference is due to the appcompat library which is compiled in by default to New Project Wizard-generated projects in Android Studio if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found