DEV Community

Discussion on: You might not need date-fns

Collapse
 
noal profile image
noal

b) tree shakable by plugins

Sorry if this is a dumb question, but: what plugin? how? I wasn't able to find anything about this for searches like 'DayJS tree shaking plugin'. The only thing Google was leading me to was Webpack's tree shaking. Is that what you mean?

Collapse
 
dmtrkovalenko profile image
Dmitriy Kovalenko • Edited

It means that the architecture itself build over plugins day.js.org/docs/en/plugin/plugin, so basically, you can not import a specific plugin until you need it.

So if chunk A only does simple formatting – dayjs weights 2kb, but another chunk can add some functionality like timezones day.js.org/docs/en/plugin/relative... and this code will be loaded only when it's really needed.