🐎 Allow some country's regions to be included/excluded by tree shaking
See original GitHub issueA package that uses this package must include or exclude all data for all countries. For a web UI that only needs regions for some countries, this makes country-region-data
an unnecessarily very large part of its bundle.
It would be nice if data could be imported by country, so that data for unused countries is not included in the bundled app.
E.g.
import countriesOnly from 'country-region-data/countries'
import { us, ca } from 'country-region-data/regions'
or
import countriesOnly from 'country-region-data/countries'
import us from 'country-region-data/us'
import ca from 'country-region-data/ca'
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >Reduce JavaScript payloads with tree shaking - web.dev
Tree shaking is a form of dead code elimination. The term was popularized by Rollup, but the concept of dead code elimination has...
Read more >Tree shaking and code splitting in webpack - LogRocket Blog
Tree shaking, also known as dead code elimination, is the practice of removing unused code in your production build. It's important to ship...
Read more >Tree shaking - MDN Web Docs Glossary
Tree shaking is a term commonly used within a JavaScript context to describe the removal of dead code. It relies on the import...
Read more >TIP 61 Behavioral Health Services for American Indians and ...
The TIP presents culturally adapted approaches for the prevention and treatment of addiction and mental illness, as well as counselor competencies for providing ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll do this for the next release. Thanks!
Hey @BevanR, very sorry for the wait. The country array tuples sounds fine. Yeah I can see how that could be useful.
This would increase the size of the UMD file, but to be honest I’m not too worried. Any modern application would be using the es6 file by now, so a little extra weight to the file is fine given that it’s tree-shakeable. I should have time tomorrow to get a new version out containing this addition.