Skip to content
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

Consolidate all symbols in a single file #11629

Merged
merged 2 commits into from
Nov 22, 2017

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 22, 2017

This reduces the code duplication as we have quite a few of them now. It's also nice to be able to see them all together. Note this is shared/ so they're still duplicated between React and renderer packages.

The actual file savings are negligible (a few dozen bytes after gzip for combined bundles). This is mostly to make it better from code organization perspective.

I tried putting them as a hidden export on the React object but this actually increased the size a bit because our secret export name is longer than the code this saves. 😛 Although maybe it would be nice to do in the future to fix cases like #8379 (comment). For now I decided not to do it.

This reduces the code duplication as we have quite a few now.
@sebmarkbage
Copy link
Collaborator

Seems fine but there was a reason to colocate them to begin with. The idea is that others shouldn't be asking for a canonical module to import these from, creating dependency quirks. Instead it should be duplicated. So if we colocate then it is easier for others to copy that pattern rather than try to import some module. E.g. by reaching into internals or trying to copy it from the React project.

@gaearon
Copy link
Collaborator Author

gaearon commented Nov 22, 2017

They can't reach into React anymore anyway (thanks to flat bundles) so that's not a concern now. Thanks for explaining!

@gaearon gaearon merged commit 1cb6199 into facebook:master Nov 22, 2017
raphamorim pushed a commit to raphamorim/react that referenced this pull request Nov 27, 2017
* Consolidate all symbols in a single file

This reduces the code duplication as we have quite a few now.

* Record sizes
Ethan-Arrowood pushed a commit to Ethan-Arrowood/react that referenced this pull request Dec 8, 2017
* Consolidate all symbols in a single file

This reduces the code duplication as we have quite a few now.

* Record sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants