-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add a plugin to webpack config w/o ejecting #1060
Comments
Maybe it's time for somebody to fork moment and make it Webpack-friendly if they'd rather not fix it? It's really not right that a library requires changes in the config. And no, we don't intend to allow modifying Webpack configs as this defeats the purpose of this tool. Your best bet would be to bring this up with Moment maintainers (this issue has been affecting people for years) or fork it. |
Ok thanks. It's been pointed out a long time ago to |
I think it's more of a problem with Moment than with Webpack. |
Oh, yeah, my mistake! I meant "momentjs maintainers". Seems like they're working on it after all! webpack/webpack#3128 |
FWIW if you need something similar to Moment but not suffering from this issue, I recommend date-fns. |
@gaearon thanks for the suggestion and the time you're taking to reply to me, that's what I'd use as I discovered it while looking for an alternative to moment but the date/timepicker I'm using requires moment. I tried to find one using date-fns but haven't found any, I'll try to search again. Maybe I should create one but I'm not sure it'd fit in the current budget of my client 😊 |
@orditeck I used to be in your situation... all I need is a simple date picker and 200 of KB from momentjs come into my app. Now in my simple cases, I just use select boxes.. However, in complex case that a date picker is a must, I suggest you to consider libraries that are not 'react' yet. It is actually quite easy to use any libraries with react, because they are just JS after all. If you already have jquery, then https://github.com/amsul/pickadate.js might be a good choice since it is not depend on momentjs. I think you can even find one that is not depend on any thing at all. Ps. of course create a new one for community is always appreciate =)) |
@orditeck hi. I forked this repository and added the possibility to modify webpack configs. You can take a look at it here: https://github.com/ezhlobo/react-scripts |
@gaearon seems like react-scripts could help protect the user transparently here by adding the context replacement plugin. I generally agree with you that this is moment's problem. However, pragmatically:
I reallly understand not wanting to have a bunch of special cases for user libraries, However maybe it's worth making an exception for community projects that are used extensively? |
I’d like to, but how do we distinguish from legit cases if people want to bundle those locales? |
I'd suggest that no one ever wants to bundle a 115 locales at once. The Ignore would just prevent them from being bundled automatically (as far as I've seen) when you require |
This seems sensible. Want to send a PR? |
Is that possible? I'm using moment and it loads all the locales (so moment takes 200kB instead of 50kB in the build), the current fix for more than one year seems to be to exclude the locales via webpack using:
I tried to add it manually to
/node_modules/react-scripts/config/webpack.config.prod.js
and it works but I can't do that, and I don't want to eject.The text was updated successfully, but these errors were encountered: