rxaviers / cldr-data-npm

Npm module for Unicode CLDR JSON data
MIT License
42 stars 28 forks source link

Keep data in a single place #28

Open rxaviers opened 8 years ago

rxaviers commented 8 years ago

Can we keep the data in one single/global place to avoid unnecessary downloads and to avoid unnecessary disk usage? For example, in ~/.npm/cldr-data/<version>. More details: the files of this repo would be normally installed by npm and therefore placed in each local node_modules path, but our post-install script would download CLDR into a global place (and avoid to re-download it in case it was already downloaded); then link those files for the respective node_modules install, so they can be accessed.

Benefits:

TODOs:

bajtos commented 8 years ago

FWIW, you can take a look at how https://www.npmjs.com/package/phantomjs-prebuilt is handling re-use of downloaded data.

puzrin commented 7 years ago

Does require('cldr-data/<arbitrary-json-file-path.json') still work using this approach?

That's dangerous and make project fragile. Npm cache can be cleaned by different reasons with external tools. That should not fuckup project.

There still a chance to cache downloads, but those are 10x size less than unpacked data. Not a big deal.

rxaviers commented 7 years ago

Basically the feedback I got so far is: let's cache the downloaded packages, not the actual uncompressed cldr-data.

This would prevent re-downloading CLDR, but it wouldn't help de-duplicate disk usage. Not saying it's good or bad, I'm just posting this comment to sum it up.

SlexAxton commented 7 years ago

I think I agree in general with that approach (cache the resource but redo the work). It might be nice to support checking a sha-sum of the expected files somewhere so one dependency can't poison the other dependencies by putting bad data in the right spot.

In my experience reducing network activity is probably going to pay off a lot more than reducing a few mb on the hard drive.