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.

🐎 Allow some country's regions to be included/excluded by tree shaking

See original GitHub issue

A 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
benkeencommented, Dec 17, 2021

I’ll do this for the next release. Thanks!

0reactions
benkeencommented, Feb 22, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

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