-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Reorganize Src Directory for Isomorphic React Package #3866
Conversation
cc @zpao |
For my own notes. There are some unfortunate dependencies from /isomorphic right now that we should resolve. ReactCurrentOwner.js - Needed for refs. We'll need to require this from each renderer so that they can update it. flattenChildren.js and traverseAllChildren.js - Used both in reconcilers and children helpers. Not sure how to best share this code. PooledClass.js - We can probably just simplify this code and drop the dependency. ReactErrorUtils.js - This call is in the wrong place anyway which leads to bad production bugs at FB. Should move it into the event system. ReactFragment.js - Should ideally be deprecated ASAP. ReactUpdateQueue.js, ReactInstanceMap.js and ReactLifeCycle.js - Current the classes have a direct connection into this code. Effectively we need a pointer from the instance to the "active" renderer to get to these. Makes it not possible to make ReactInstanceMap just a Map. ReactNativeComponent.js - Don't remember why we needed this but if we want isomorphic components we can't know ahead of time what a string element will render into. We can make heuristics at best. |
The new folder structure is best reviewed at: https://github.com/sebmarkbage/react/tree/coreapi/src |
Fixed lint. Now passing travis. |
lgtm. Still not wild about "isomorphic" but it doesn't matter (yet) |
Will this be getting another step closer to react-native not needing to fork react due to some of the DOM dependencies? |
(asking blindly without looking at the code) :) |
yes. Also lets server rendering use a different implementation. |
b97bf3d
to
32fd92b
Compare
return; | ||
} | ||
alreadyInjected = true; | ||
|
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.
👏 pretty sure this is exactly what I need right now.
The new folder structure is organized around major packages that are expected to ship separately in some form. `/isomorphic` I moved classic/modern and children utils into a directory called "isomorphic" with the main export being ReactIsomorphic. This will eventually become the "react" package. This includes all the dependencies that you might need to create a component without dependencies on the renderer/reconciler. The rest moves into decoupled renderers. `/renderers/dom/client` - This is the main renderer for DOM. `/renderers/dom/server` - This is the server-side renderer for HTML strings. `/addons` and `/test` - Same as before for now. You're not supposed to take on a dependency inside another package. Shared code is organized into a "shared" directory which is intended to support all the packages in that subdirectory. Meaning that once we swap to CommonJS modules, the only time you should use `..` is to target `../shared/` or `../../shared`. E.g. `/shared/` is common utils that are used by everything. `/renderers/shared/` is code that is shared by all renderers, such as the main reconciliation algorithm. Shared code will likely be copied into each package rather than referenced. This allow us to have separate state and allow inlining and deadcode elimination.
Reorganize Src Directory for Isomorphic React Package
The new folder structure is organized around major packages that are expected to ship separately in some form.
/isomorphic
I moved classic/modern and children utils into a directory called "isomorphic" with the main export being ReactIsomorphic. This will eventually become the "react" package.
This includes all the dependencies that you might need to create a component without dependencies on the renderer/reconciler.
The rest moves into decoupled renderers.
/renderers/dom/client
- This is the main renderer for DOM./renderers/dom/server
- This is the server-side renderer for HTML strings./addons
and/test
- Same as before for now.You're not supposed to take on a dependency inside another package.
Shared code is organized into a "shared" directory which is intended to support all the packages in that subdirectory. Meaning that once we swap to CommonJS modules, the only time you should use
..
is to target../shared/
or../../shared
.E.g.
/shared/
is common utils that are used by everything./renderers/shared/
is code that is shared by all renderers, such as the main reconciliation algorithm.Shared code will likely be copied into each package rather than referenced. This allow us to have separate state and allow inlining and deadcode elimination.