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

Reorganize Src Directory for Isomorphic React Package #3866

Merged
merged 1 commit into from
May 16, 2015

Conversation

sebmarkbage
Copy link
Collaborator

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.

@sebmarkbage
Copy link
Collaborator Author

cc @zpao

@sebmarkbage sebmarkbage changed the title Reorganize Files for Isomorphic React Package Reorganize Src Directory for Isomorphic React Package May 14, 2015
@sebmarkbage
Copy link
Collaborator Author

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.

@sebmarkbage
Copy link
Collaborator Author

The new folder structure is best reviewed at: https://github.com/sebmarkbage/react/tree/coreapi/src

@sebmarkbage
Copy link
Collaborator Author

Fixed lint. Now passing travis.

@zpao
Copy link
Member

zpao commented May 16, 2015

lgtm. Still not wild about "isomorphic" but it doesn't matter (yet)

@iamdustan
Copy link
Contributor

Will this be getting another step closer to react-native not needing to fork react due to some of the DOM dependencies?

@iamdustan
Copy link
Contributor

(asking blindly without looking at the code) :)

@sebmarkbage
Copy link
Collaborator Author

yes. Also lets server rendering use a different implementation.

@sebmarkbage sebmarkbage force-pushed the coreapi branch 2 times, most recently from b97bf3d to 32fd92b Compare May 16, 2015 01:29
return;
}
alreadyInjected = true;

Copy link
Contributor

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.
sebmarkbage added a commit that referenced this pull request May 16, 2015
Reorganize Src Directory for Isomorphic React Package
@sebmarkbage sebmarkbage merged commit 5275244 into facebook:master May 16, 2015
@sebmarkbage sebmarkbage mentioned this pull request Jun 4, 2015
25 tasks
@sebmarkbage sebmarkbage mentioned this pull request Aug 11, 2015
7 tasks
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.

5 participants