Skip to content
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

Bundle size extremely large due to inclusion of cities database #60

Closed
taylorthurlow opened this issue Jun 7, 2021 · 14 comments
Closed

Comments

@taylorthurlow
Copy link
Contributor

Hi, I'm wondering if there are any plans to address the size of the included JSON database. Uncompressed, the countries, states, and cities databases are more than 16 megabytes, which is still more than 2.5 when fetched with a browser, gzip compressed.

This is sort of a deal-breaker for using this application in production for just countries and states, but would be 100% more usable if there were an option to exclude the cities database when one has no intention of using it. I don't know much about tree shaking and module exclusion, nor do I know how/if that would related to a big JSON document.

Maybe @dr5hn has an opinion or suggestions on this topic?

@taylorthurlow
Copy link
Contributor Author

Opened #62 to address this

@dr5hn
Copy link
Contributor

dr5hn commented Jun 10, 2021

@taylorthurlow
This looks like a critical issue, thanks for putting this up !!

It certainly needs an attention @harpreetkhalsagtbit

@TAnas0
Copy link

TAnas0 commented Jun 11, 2021

Interested for the same reasons. My bundle size is getting too big, I started thinking of dropping the NPM package.
Once PR #62 is released, it'd be glad to test it.

@harpreetkhalsagtbit
Copy link
Owner

@dr5hn @taylorthurlow @TAnas0
I will pick this up tomorrow.

@taylorthurlow
Copy link
Contributor Author

Great to hear, thanks. I just pushed up rewritten and passing tests to #62.

@harpreetkhalsagtbit
Copy link
Owner

harpreetkhalsagtbit commented Jun 12, 2021

I have refactored complete package - Tree Shaking
Please test beta version - npm i country-state-city@2.1.0-beta.2

@taylorthurlow @dr5hn @TAnas0

@JakeAi
Copy link

JakeAi commented Jul 28, 2021

@harpreetkhalsagtbit Why was this issue closed? It didn't fix tree shaking. Bundles are still 17+mb. I ended up using @taylorthurlow fork which allows tree shaking.

@cmacdonnacha
Copy link

cmacdonnacha commented Sep 2, 2021

Same here, bundle size is 17Mb. I wonder if this PR was actually included in the release?

@cmacdonnacha
Copy link

@taylorthurlow Can you verify that tree shaking now works for you?

@harpreetkhalsagtbit
Copy link
Owner

@cmacdonnacha @taylorthurlow @dr5hn
I tested this before merging. I don't know whats wrong. I didn't get time to check this again.

Would you all please share the package version you are testing and also share some code that fails.

@cmacdonnacha
Copy link

cmacdonnacha commented Sep 3, 2021

@harpreetkhalsagtbit Sure, package version is 3.0.1 and sample code is

import { Country, State } from 'country-state-city';
console.log(Country.getAllCountries())
console.log(State.getStatesOfCountry('US'))

@taylorthurlow
Copy link
Contributor Author

@taylorthurlow Can you verify that tree shaking now works for you?

Sorry my priorities changed and I haven't switched over from my fork yet.

@mathycoder
Copy link

Hi, any updates on this? My bundle is also over 16 MB, and it seems impossible to tree shake city.json.

@atomauro
Copy link

Same issue, mobile is not loading properly due to this JOLY bundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants