OpenBookPrices / country-data

Country related data such as ISO codes, currencies etc
MIT License
512 stars 166 forks source link

Usage with webpack? #57

Closed cscognamiglio closed 8 years ago

cscognamiglio commented 8 years ago

Hi, I am not getting how to use it with webpack&c:

import CountryData from 'country-data'; CountryData.lookup.countries({currencies: 'EUR'});

generates: Uncaught (in promise) TypeError: data.filter is not a function(…)

Am I doing something wrong?

evdb commented 8 years ago

I don't use webpack so can't comment. Anyone else have any observations?

dadambickford commented 8 years ago

Same issue. Throwing a debugger in the script where I'm importing 'country-data', countryData.countries.all returns an empty object.

freen commented 8 years ago

Same issue.

import countryData from 'country-data';
console.log(countryData);

screen shot 2016-08-04 at 16 45 38

evdb commented 8 years ago

I'd like to fix this. As I've never used webpack please could you provide me with the steps needed to reproduce this error starting from an empty directory. The more detailed the better, and if it can be easily adapted into a test case that would be superb. :) On Thu, 4 Aug 2016 at 16:46, freen notifications@github.com wrote:

Same issue.

import countryData from 'country-data'; console.log(countryData);

[image: screen shot 2016-08-04 at 16 45 38] https://cloud.githubusercontent.com/assets/1816457/17406240/f03c368e-5a62-11e6-86a6-262174b646c8.png

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/OpenBookPrices/country-data/issues/57#issuecomment-237575680, or mute the thread https://github.com/notifications/unsubscribe-auth/AALc7knzWs5f8mK04XYRECgywkFNQUk2ks5qcftDgaJpZM4JYYSt .

luxflux commented 8 years ago

I had to install and configure json-loader in webpack to fix this:

npm install json-loader --save-dev
// webpack.config.js

// ...
   loaders: [
      // other loaders
      { test: /\.json$/, loader: 'json' },
  ],
// ...
evdb commented 8 years ago

Thank you @luxflux - would adding the webpack.config.js file to country-data be a way to close this issue?

luxflux commented 8 years ago

Hm, I'm pretty new to this stuff as well... But I don't think adding webpack.config.js would help as this is a config which is project specific and won't automagically be searched in the dependencies. IMHO mentioning this in the README would be sufficient.

evdb commented 8 years ago

Thanks for the input. Notes about webpack added to README and code now on NPM as v0.0.28