Date-fns: Add option for using / publishing one package per function

Created on 3 Aug 2018  路  3Comments  路  Source: date-fns/date-fns

馃憢 Thanks so much for all your hard work on this awesome library!

It would be really helpful for applications where disk space is a constraint and a bundler isn't the most viable option (e.g. scripts for Electron apps) to be able to pull in individual packages for only the functions you need. For example, if you only needed to use distanceInWords(), you could run something like:

npm install @date-fns/distance-in-words

and only install the code needed for that one function. For a point of comparison, Lodash offers the option of per-method packages in addition to function-per-file-in-one package style date-fns uses already.

Let me know if there's any more information I could provide that'd be helpful!

鈽狅笍 Won't fix 馃帀 Feature

Most helpful comment

If I could do it again I wouldn't produce lodash.assign, lodash.clonedeep and others. It's a maintenance pain. Folks end up reaching for them thinking they'll get a smaller bundle but the fact is that plain old lodash or lodash-es + lodash-webpack-plugin or babel-plugin-lodash end up creating smaller bundles. If I could go back I'd focus folks on the primary modular package instead offering individual packages.

All 3 comments

@mnquintana Thanks for your kind words!

I like the idea but I have a concern: the people will start getting duplicated code because of dependencies using different versions, date-fns and @date-fns/distance-in-words, etc.

@jdalton could you please tell me what's your experience of having lodash.assign, lodash.clonedeep, etc. with lodash?

If I could do it again I wouldn't produce lodash.assign, lodash.clonedeep and others. It's a maintenance pain. Folks end up reaching for them thinking they'll get a smaller bundle but the fact is that plain old lodash or lodash-es + lodash-webpack-plugin or babel-plugin-lodash end up creating smaller bundles. If I could go back I'd focus folks on the primary modular package instead offering individual packages.

@jdalton good point, thanks!

@mnquintana I think it's out-of-scope to provide individual packages in order to reduce disk space. It would be great to have a dedicated tool for reducing package size but it's definitely that we can't focus on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

duro picture duro  路  3Comments

pedrobrost picture pedrobrost  路  3Comments

djleonskennedy picture djleonskennedy  路  3Comments

rosieks picture rosieks  路  3Comments

sconway picture sconway  路  3Comments