-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Make dependencies of react package optional #6252
Conversation
Rationale: The package is entirely usable without the envify and fbjs dependencies.
CLA Signed BTW. |
Why not devDependencies then if they aren't needed? |
I might be wrong but I think |
Fbjs is not optional. Envify is there for use with browserify so could probably be called optional. |
I don’t think making |
(First of all, thanks for the involvement and sorry for creating a pull request instead of an issue even though I knew this wouldn't be a drive-by pull request.) I'm claiming the package is usable without the Regarding |
Yeah, but the same can be said about React itself. The fact that it exists in
React relies on envification in order for CommonJS consumers to be able to get both development and production build depending on the configuration. Different build tools have different approaches to envification. Webpack has the stance that libraries should ship compiled code, and any further transformations should be done manually by the user if necessary. Browserify decided that libraries can declare the necessary transformations. Both approaches have upsides and downsides, but they are already ingrained in the respective communities. If we remove the Browserify transformation step, most today’s Browserify consumers will get development builds in production. This is because, without Having a separate package like Browserify was the first successful mainstream CommonJS bundler and we can’t ignore its conventions even if in some cases they seem suboptimal. Having transitive dependencies because of a build tool you don’t use can indeed be frustrating, but breaking all users of the most popular bundler or introducing major inconsistency in using React with it seems like a worse kind of problem to me. I think that with the current situation your best bet would be to either use React from a CDN, or set up a mirror npm package where you only bring the dist files and remove the dependencies. Sorry I can’t be more helpful than that! |
Great back and forth, thanks for explaining it Dan. Apologies for my curtness, I'm on my phone at the beach 🏖 One option to cut down on deps for the browserify case is to switch to using loose-envify which only has 1 additional dependency and should work fine since we don't have any crazy uses of process.env. |
Sounds great. @qerub Would you like to take a stab at PR? |
I am closing this per the discussion above. We would be happy to accept a different PR that switches React to use Thank you for taking time to contribute, and we hope to see you again! |
Thanks for the thorough explanation of your reasoning. I have now submitted a pull request (#6303) for the |
Rationale: The package is entirely usable without the envify and fbjs dependencies.
This change might affect projects using
npm install --no-optional
.