I use only a few of the functions and made sure I import them as recommended for tree-shaking in their documentation :
import { parseISO, formatDistanceToNow } from 'date-fns'
import { fr } from 'date-fns/locale';
The code itself works fine, but when I look at the resulting JS bundle, the entire libray (all functions) along with all of the locales are bundled, resulting in ~1,37mb > parsed 600kb > Gzipped 111kb. I use NuxtJS (bundling with webpack) and the latest date-fns (2.27.0).
Here is the bundle generated :
Based on the answer to this similar question :
date-fns 2 - can't get tree-shaking to work
I've double-checked the final webpack config generated by nuxt, and it contains as expected mode: production. I am not using TypeScript on this project.
Also went through several related github issues like this one : https://github.com/date-fns/date-fns/issues/2589
None of the answers worked in my situation... what can I do to make the tree-shaking happen properly ? Let me know if you think my question is missing some information :)
