Uh oh!
There was an error while loading. Please reload this page.
Replace country-regex with i18n-iso-countries - #7366
Conversation
gvwilson
commented
Feb 18, 2025
thanks @dimitrov570 - I'll see if we can get this into the 3.1 release. |
camdecoster
left a comment
There was a problem hiding this comment.
Thanks for your contribution! I left a few comments. Could you please merge master and handle the merge conflicts?
@gvwilson there are 6 codes removed from the new package. Would this count as a breaking change? The countries don't exist anymore.
| Code | Country |
|---|---|
| ANT | Netherlands Antilles |
| CSK | Czechoslovakia |
| DDR | German Democratic Republic |
| EAZ | Zanzibar |
| YMD | South Yemen |
| YUG | Yugoslavia |
| @@ -0,0 +1 @@ | |||
| - Replace country-regex with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] No newline at end of file | |||
There was a problem hiding this comment.
| - Replace country-regex with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] | |
| - Replace country-regex package with i18n-iso-countries [[#7366](https://github.com/plotly/plotly.js/pull/7366)] |
| // make list of all country iso3 ids from at runtime | ||
| var countryIds = Object.keys(countryRegex); | ||
| const countries = require("i18n-iso-countries"); |
There was a problem hiding this comment.
Could you please move this require statement above with the others?
gvwilson
commented
Jul 30, 2025
I don't think the deleted countries counts as a breaking change. |
camdecoster
commented
Jul 30, 2025
I clicked the wrong button. Let me know when you make changes and I'll review again. |
dimitrov570
commented
Aug 5, 2025
Sorry, I was away. Let me know if anything else needs to be done. |
camdecoster
commented
Aug 5, 2025
Welcome back! There's a couple of failing tests due to the library change and country names not being available anymore. I should have it fixed today, then I'll merge it. |
dimitrov570
commented
Aug 5, 2025
You would fix it or I should fix it? I'm not 100% sure what needs to be done, but I suppose just to remove the countries that are not present anymore from the tests, right? |
camdecoster
commented
Aug 5, 2025
I took care of it. Once CI passes, I'll get it merged. |
camdecoster
commented
Aug 5, 2025
For future reference, there was an issue where ESBuild was treating the required en.json file as JavaScript instead of JSON. The error I saw was this: plotly.js/tasks/compress_attributes.js Lines 38 to 56 in bddbb14 I'm not sure why this happened because ESBuild can handle JSON files, but it was necessary to stringify the JSON to get ESBuild to recognize the file as JSON. An alternative that worked was to wrap the text in On another note, the library that this PR replaces uses RegEx patterns to match country names which is pretty flexible (though a bit out of date). The new library looks for an exact match of lowercased strings. As such, some previous country names no longer find a match. For example, a location of Burma no longer returns the country code for Myanmar and a location of Moldova no longer matches because it needs to be "Moldova, Republic of". There are some open PRs to add alternative names (like just "Moldova"), but those haven't been getting approved very quickly. Once they do, we can update the library and make the country lookup a bit better. |
emilykl
commented
Aug 6, 2025
@camdecoster For the country names that have changed, this will be a breaking change for charts showing those countries and using Ultimately seems like we might want to eventually phase out |
camdecoster
commented
Aug 8, 2025
Since this could be a breaking change, we're going to hold off until v4. I added a breaking change warning in 3.1.0. @gvwilson what's the best way to track this so we don't forget it? |
camdecoster
commented
Jun 22, 2026
FYI, I decided to spin up a custom library to handle lookups (country-iso-search) and that was recently added to the v4.0 branch in #7856. Thanks for your work on this. I'm going to close this PR since the work was completed in #7856. |
Resolves the issue discussed in #7026.
This implementation does not use regular expressions as before and does not contain countries that do not exist anymore, compared to the previous solution with
country-regex. But on the other handi18n-iso-countriesseems to be updated frequently, so it will contain updated information on country codes.