manuelmhtr / countries-and-timezones

Minimalistic library to work with countries and timezones data
MIT License
224 stars 67 forks source link

Error with using getAllCountries method in next.js 11 #32

Closed bfeldner closed 3 years ago

bfeldner commented 3 years ago

We are using the getAllCountries method in our next.js v. 11 project, which stopped working when updating countries-and-timezones from 2.4 to 2.5.0.

Made a minimal example showing the error: https://codesandbox.io/s/nextjs-forked-5uj7q

manuelmhtr commented 3 years ago

Hi @bfeldner, thanks for reporting this problem. Apparently the ESM build is only exporting a default (the whole package) but not individual functions.

As a quick fix, this should work:

import ct from "countries-and-timezones";

const App = () => {
  const allCountries = ct.getAllCountries();

However, let me try other solutions to make import { getAllCountries } from "countries-and-timezones"; works as well.

bfeldner commented 3 years ago

Hi @manuelmhtr , thank you for your response.

manuelmhtr commented 3 years ago

Hi @bfeldner, I just released version v3.0.1 which supports named ESM exports. Your original code should work with this version.