-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Context Replacement Plugin #2524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add example on how to tree shake locales from date-fns
Please sign CLA. |
I wonder though if it would be usefull to show also how the dynamic import is also happening in the place of use to avoid some possible confusion |
Wasn't moment example enough for a developer to figure out how to tree shake in similar cases? I mean after seeing two similar examples future contributors might want to put their use cases into example and we end up maintaining them (after example's lib releases breaking change to their structure and this regex wont fit anymore) |
I had really hard time figuring this out as we're not checking against filename but filepath. In moment we have a lot of files named after their locales const getLocale = locale => require(`moment/locale/${locale}.js`) While in date-fns it is folder name that we need to check: const getLocale = locale => require(`date-fns/locale/${locale}/index.js`) It took me some find to find a solution that would properly solve the issue of packing all locales so I decided to suggest this change to avoid this pain for someone that might be looking for this solution. If you're afraid of maintaining each time library example maybe giving a link to solution would be a good option? date-fns docs/webpack? |
Hi @masives |
replace date-fns description with link to documentation
I apologize for taking so long. @EugeneHlushko idea seems perfect for me, PR has been updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty!
@montogeek pls review |
Thanks! |
Add example on how to tree shake locales from date-fns.