node-convict icon indicating copy to clipboard operation
node-convict copied to clipboard

Drop dependency on moment.js?

Open terlar opened this issue 6 years ago • 5 comments

Would it be possible to drop the dependency on moment? I want to use node-convict in a smaller project, but the fact that it depends on moment which pulls in quite a substantial amount of code I have to second guess if I can use it. Perhaps some smaller date function library could replace it?

I also noticed yargs, which seem to have a limited use, what is it used for today?

Thanks for a very useful package.

terlar avatar Aug 23 '19 15:08 terlar

image

It is only dev dependencies : https://github.com/moment/moment/blob/develop/package.json#L39

npm install --save-prod

A-312 avatar Aug 23 '19 15:08 A-312

I'm sorry if I was unclear, I meant moment itself:

$ du -hs moment
3.5M    moment
$ find moment -name '*.js' | wc -l
367
$ find moment -name '*.js' -exec cat {} \; | wc -l
56957

It is quite a substantial amount for smaller things.

terlar avatar Aug 23 '19 19:08 terlar

I looked into this at one point. The ideal thing to do here would be to replace Moment with dayjs, which is designed to be a lighter but API compatible drop-in replacement. Unfortunately, dayjs doesn't yet support .duration() - I've been following this issue, and hoping it gets merged in soon, but progress seems slow.

brettneese avatar Aug 25 '19 22:08 brettneese

Or add duration and timestamp like a dependencie with addFormat.

convict.addFormat(require('convict-duration'))

A-312 avatar Sep 09 '19 08:09 A-312

Next step:

  • [ ] Yargs should be optional

A-312 avatar Apr 11 '20 05:04 A-312