-
Notifications
You must be signed in to change notification settings - Fork 45.7k
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
Move renderer host configs into separate modules #12791
Conversation
Details of bundled changes.Comparing: c802d29...53b03e4 react-art
react-native-renderer
Generated by 🚫 dangerJS |
It seems like there are three ways we could do this. 1. Split Host Config and Renderer (i.e., this diff)ReactDOMHostConfig.js:
ReactDOM.js:
2. Host Config and Renderer as separate exportsI understand that ES6 modules allow circular imports. So I think that means we can do something like: ReactDOM.js:
and ReactFiberReconciler can import the host config from here. This way we don't need to split them up, which might be more convenient. 3. Like now, with a little dynamic injectionThat is, continue having ReactFiberReconciler export a function. I guess that would need to look something like:
And then ReactDOM.js unchanged. Which I'm sure Seb will hate, but it would be nice to do this because then we can match the external API for our internal renderers. ?I don't feel qualified to know which is best here. |
The approach I wanted to do is similar to what you suggested in (1) except we'd have an This is why I want to go all-in on ES6 modules and avoid a reified object In terms of expressing it in code, custom renderers would keep doing import reconciler from 'react-reconciler';
var Thing = reconciler(config); but our renderers would do this: import * as ReactDOM from 'react-reconciler/inline'; // inline = magic! I can push up a proof of concept for how this could work soon. TLDR:
|
I also don't think splitting is that inconvenient. In case of RN/RF it got a bit cleaner IMO. |
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.
I read the discussion on the PR. It makes sense. I also scanned the changes and they seem to be as expected (just splitting things out into the separate host config files as an initial step).
So ... high-level LGTM from me 👍
I did some build diffing and I think this is correct. DOM bundle looks closest, other bundles have the order of modules switched up a little bit but the end result should be the same. |
* Separate test renderer host config * Separate ART renderer host config * Separate ReactDOM host config * Extract RN Fabric host config * Extract RN host config
I tried resolving host configs statically but it's hard right now because the host config is all over the place in the renderer code.
If we want to resolve the host configs statically, we're going to need to put them into separate modules (so that we can use ES imports for better mangling, and to override resolving on the file level).
I'm working just on that step here. It doesn't change anything from the reconciler's point of view. In some cases (such as with test renderer) I'll have to create a third file that keeps mutable private state that's accessible both by the renderer public API and the host config.
I did this for all host configs except
react-noop-renderer
. This is because we usereact-noop-renderer
, among other things, for testing the npmreact-reconciler
package, and the way it's written now with inline reconciler calls reflects how external renderers will continue consuming it. When we add inlining, we'll want to keep that system working.The diff appears as if there were a lot of changes, but really it's just moving things around and tweaking what imports what. I didn't change the logic.