Skip to content

Prevent fiber code from leaking into RN stack renderer (and vice versa)#9775

Merged
bvaughn merged 1 commit intofacebook:masterfrom
bvaughn:rn-flat-bundles-pt2
May 25, 2017
Merged

Prevent fiber code from leaking into RN stack renderer (and vice versa)#9775
bvaughn merged 1 commit intofacebook:masterfrom
bvaughn:rn-flat-bundles-pt2

Conversation

@bvaughn
Copy link
Copy Markdown
Contributor

@bvaughn bvaughn commented May 25, 2017

Since stripEnvVariables was used to replace __DEV__ references, I assumed it (and other plugins) we run before requires statements were processed. Obviously I was wrong 😬 and as a result, the RN Stack and Fiber builds were way too large. This is an attempt to mimic the approach taken with DOM renderer and stub out modules that we explicitly don't want to include.

The alternative to this would have been to fork findNodeHandle, NativeMethodsMixin, ReactNativeBaseComponent, etc. and essentially avoid using the feature flag. That didn't seem tenable. The previous injection approach also doesn't work here because the circular references it resulted in caused Rollup to choke when creating the modules.

A quick smoke-test of Ads Manager and Catalyst apps (both stack and fiber) seems good. Jest tests and flow also seem good. And more importantly...

screen shot 2017-05-25 at 3 57 59 pm

Since stripEnvVariables was used to replace __DEV__ references, I assumed it (and other plugins) we run before requires statements were processed. Obviously I was wrong 😬 and as a result, the RN Stack and Fiber builds were way too large. This is an attempt to mimic the approach taken with DOM renderer and stub out modules that we explicitly don't want to include.

The alternative to this would have been to fork findNodeHandle, NativeMethodsMixin, ReactNativeBaseComponent, etc. and essentially avoid using the feature flag. That didn't seem tenable. The previous injection approach also doesn't work here because the circular references it resulted in caused Rollup to choke when creating the modules.
@bvaughn bvaughn force-pushed the rn-flat-bundles-pt2 branch from ab2c243 to 44cf03e Compare May 25, 2017 15:31
Copy link
Copy Markdown
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bvaughn bvaughn merged commit 824d22c into facebook:master May 25, 2017
@bvaughn bvaughn deleted the rn-flat-bundles-pt2 branch May 25, 2017 17:14
@sophiebits
Copy link
Copy Markdown
Collaborator

Sorry, not sure I understand. What was referencing the modules across stack/fiber? Would it be better to make the build fail when seeing those references rather than stubbing them out?

@bvaughn
Copy link
Copy Markdown
Contributor Author

bvaughn commented May 25, 2017

Would it be better to make the build fail when seeing those references rather than stubbing them out?

No, not unless we wanted to fork a dozen files to prevent stack from requiring fiber or vice versa. The problem is that RN can't rely on the same sort of injection techniques as DOM uses because Rollup chokes on the circular dependencies. And feature-flag switching isn't enough either b'c Rollup requires both branches of the conditional.

I thought I could replace ReactNativeFeatureFlags.useFiber with true or false during the build process, but the only time our plugins run is after Rollup has stitched the modules together (so too late to prevent files from being required).

So the easiest fix, at least for the short term, is to do what DOM does and just black-list a few of the entry-point files. It kind of sucks but... I did consider other options and it seems the least bad.

@gaearon
Copy link
Copy Markdown
Collaborator

gaearon commented May 25, 2017

I also think it might be better to focus on reaching full parity and getting Fiber to 100% there and not spend any more effort on debt related to Stack/Fiber separation.

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