Open dennisteambrandit opened 2 years ago
have you tried this
import {Country } from 'country-state-city';
instead of
import {Country, State, City} from 'country-state-city';
i have tried and it seems to sort of reduce size when only retrieving one country. but bundle size is huge when retrieving more.
even when usingimport {Country } from 'country-state-city';
Country.getAllCountries()
returns huge bundle size over 2 mb which includes countries/states/cities
when i map through with 16 country.iso_codes with
Country.getCountryByCode(c.country_code)
i still get a bundle returned of over 2mb which includes countries/states/cities
Next.js with Production Build
with - import {Country, State, City} from 'country-state-city
with - import { Country } from 'country-state-city
@dennisteambrandit
I also have this issue.
What I import.
import { Country } from 'country-state-city';
How I use it.
{{ props.user?.country_code ? Country.getCountryByCode(props.user.country_code).flag : '' }}
This is how big my build is including this.
This is how big my build is when I remove the above 2 lines
I'm using Laravel Mix, which uses webpack internally. All rather bizarre and odd.
Facing the same issue, bundle size is almost 16 MB. Any solution?
+1
This is stupidly big. I am afraid using this package will hugely impact on my performance.
Reduced bundle size a little bit. Please check the latest version.
have issues with large bundle size (about 2mb gzip from just city/country/state data). when looking at bundle chunk, every city/country/state is being saved in the chunk even when i am only trying to import retrieve one country.
import {Country, State, City} from 'country-state-city'; const allCountries = Country.getCountryByCode('US')