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

Copy React Reconciler modules to new fork #18548

Merged
merged 4 commits into from Apr 9, 2020

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Apr 9, 2020

Builds on top of #18285. See that PR for context and motivation.

I suggest reviewing commit-by-commit.

  • The first commit renames the existing (.old) modules. I'll land this to master in its own commit to preserve the history/blame.
  • The second commit refactors some of the internal types so they can be shared across implementations.
  • The third commit adds the forked (.new) modules. Forked modules are given a suffix of .old or new. It does change any of the implementation. They are the same except for the imports. The changes in this commit are autogenerated. (Refer to the commit message for exact steps.)
  • The fourth commit points Rollup, Jest, and Flow at the new implementation's entry points.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 9, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 9, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 168215d:

Sandbox Source
zealous-dawn-dnqgk Configuration

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 9, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4c6470c:

Sandbox Source
focused-pare-xqotk Configuration

@acdlite acdlite force-pushed the fork-reconciler branch 2 times, most recently from ec82c91 to a48cf16 Compare April 9, 2020 03:07
@sizebot
Copy link

sizebot commented Apr 9, 2020

Details of bundled changes.

Comparing: 147bdef...4c6470c

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 632.15 KB 632.85 KB 133.21 KB 133.39 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 107.12 KB 107.12 KB 32.44 KB 32.44 KB UMD_PROD
react-art.development.js +0.1% +0.2% 536.55 KB 537.23 KB 115.65 KB 115.83 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 72.11 KB 72.11 KB 21.66 KB 21.66 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 598.34 KB 599.02 KB 125.4 KB 125.58 KB FB_WWW_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.1% +0.2% 567.91 KB 568.61 KB 118.1 KB 118.28 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.13 KB 74.13 KB 22.52 KB 22.52 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% -0.0% 38.71 KB 38.71 KB 9.42 KB 9.42 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.73 KB 12.73 KB 3.96 KB 3.96 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.2% 541.51 KB 542.19 KB 116.76 KB 116.93 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 73.93 KB 73.93 KB 22.23 KB 22.23 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.1% 575.37 KB 576.04 KB 121.34 KB 121.51 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.1% 653.4 KB 654.07 KB 140.26 KB 140.45 KB RN_OSS_DEV
ReactFabric-dev.js +0.1% +0.1% 635.11 KB 635.78 KB 135.83 KB 136.03 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% 0.0% 274.31 KB 274.31 KB 47.25 KB 47.25 KB RN_OSS_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js 0.0% 0.0% 119.64 KB 119.64 KB 37.5 KB 37.5 KB NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 75.12 KB 75.12 KB 20.11 KB 20.11 KB UMD_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 405.08 KB 405.08 KB 73.46 KB 73.46 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% 0.0% 22.82 KB 22.82 KB 8.48 KB 8.49 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.51 KB 123.51 KB 38.67 KB 38.67 KB NODE_PROFILING
react-dom-test-utils.production.min.js 0.0% 0.0% 13.22 KB 13.22 KB 4.89 KB 4.9 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 697 B 698 B UMD_PROD
react-dom-server.node.development.js 0.0% 0.0% 147.06 KB 147.06 KB 38.88 KB 38.89 KB NODE_DEV
ReactDOMForked-dev.js +0.1% +0.1% 1007.09 KB 1007.76 KB 223.06 KB 223.25 KB FB_WWW_DEV
ReactDOMForked-prod.js 0.0% 0.0% 421.54 KB 421.54 KB 75.83 KB 75.83 KB FB_WWW_PROD
react-dom.development.js +0.1% +0.1% 905.28 KB 905.98 KB 198.68 KB 198.86 KB UMD_DEV
ReactDOMForked-profiling.js 0.0% 0.0% 432.44 KB 432.44 KB 77.72 KB 77.72 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 155 KB 155 KB 39.38 KB 39.38 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.16 KB 1.16 KB 659 B 660 B NODE_PROD
react-dom.production.min.js 0.0% 0.0% 119.52 KB 119.52 KB 38.24 KB 38.24 KB UMD_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 22.92 KB 22.92 KB 8.51 KB 8.51 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.26 KB 123.26 KB 39.47 KB 39.47 KB UMD_PROFILING
ReactDOMTesting-dev.js +0.1% +0.1% 956.12 KB 956.79 KB 212.71 KB 212.9 KB FB_WWW_DEV
react-dom.development.js +0.1% +0.1% 861.79 KB 862.47 KB 196.23 KB 196.41 KB NODE_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 405.08 KB 405.08 KB 73.46 KB 73.46 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% 0.0% 145.85 KB 145.85 KB 38.63 KB 38.63 KB NODE_DEV
ReactDOM-dev.js +0.1% +0.1% 1007.09 KB 1007.76 KB 223.06 KB 223.25 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% 0.0% 157.98 KB 157.98 KB 39.92 KB 39.92 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 421.54 KB 421.54 KB 75.83 KB 75.83 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 69.97 KB 69.97 KB 19.6 KB 19.6 KB NODE_DEV
ReactDOMServer-prod.js 0.0% 0.0% 53.29 KB 53.29 KB 12.84 KB 12.84 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.42 KB 4.42 KB 1.54 KB 1.54 KB NODE_DEV
ReactDOM-profiling.js 0.0% 0.0% 432.44 KB 432.44 KB 77.72 KB 77.72 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 13.09 KB 13.09 KB 4.8 KB 4.8 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 56.1 KB 56.1 KB 13.84 KB 13.84 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.98 KB 9.98 KB 3.35 KB 3.36 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 53.2 KB 53.2 KB 13.64 KB 13.64 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.73 KB 9.73 KB 3.25 KB 3.25 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.1% 575.92 KB 576.59 KB 121.8 KB 121.98 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% 0.0% 16.22 KB 16.22 KB 4.91 KB 4.91 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 77.1 KB 77.1 KB 22.85 KB 22.85 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.57 KB 2.57 KB 1.08 KB 1.08 KB NODE_PROD

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 4c6470c

@sizebot
Copy link

sizebot commented Apr 9, 2020

Details of bundled changes.

Comparing: 147bdef...4c6470c

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 652.52 KB 653.22 KB 136.91 KB 137.09 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 109.73 KB 109.73 KB 33.1 KB 33.11 KB UMD_PROD
react-art.development.js +0.1% +0.2% 556.11 KB 556.79 KB 119.38 KB 119.57 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 74.66 KB 74.66 KB 22.32 KB 22.32 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 588.28 KB 588.95 KB 123.42 KB 123.6 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 240.79 KB 240.79 KB 40.69 KB 40.69 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 575.38 KB 576.05 KB 121.34 KB 121.52 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.72 KB 38.72 KB 9.42 KB 9.42 KB UMD_DEV
react-test-renderer.development.js +0.1% +0.2% 567.94 KB 568.64 KB 118.11 KB 118.29 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.16 KB 74.16 KB 22.54 KB 22.54 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.2% 541.54 KB 542.22 KB 116.77 KB 116.95 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 73.96 KB 73.96 KB 22.25 KB 22.25 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js 0.0% 0.0% 156.59 KB 156.59 KB 39.58 KB 39.58 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 127.78 KB 127.78 KB 39.88 KB 39.89 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 979.21 KB 979.88 KB 217.08 KB 217.26 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 408.63 KB 408.63 KB 73.95 KB 73.95 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 75.14 KB 75.14 KB 20.11 KB 20.12 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 13.23 KB 13.23 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js +0.1% +0.1% 929.57 KB 930.24 KB 207.07 KB 207.26 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% 0.0% 69.98 KB 69.98 KB 19.61 KB 19.61 KB NODE_DEV
react-dom-server.node.development.js 0.0% 0.0% 148.58 KB 148.58 KB 39.1 KB 39.1 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.1 KB 13.1 KB 4.81 KB 4.81 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 23.69 KB 23.69 KB 8.72 KB 8.72 KB NODE_PROD
react-dom-server.browser.development.js 0.0% 0.0% 147.36 KB 147.36 KB 38.84 KB 38.84 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 23.28 KB 23.28 KB 8.56 KB 8.57 KB NODE_PROD
react-dom.development.js +0.1% +0.1% 935.2 KB 935.9 KB 203.96 KB 204.14 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 56.11 KB 56.11 KB 13.85 KB 13.85 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 123.6 KB 123.6 KB 39.39 KB 39.4 KB UMD_PROD
ReactDOMForked-dev.js +0.1% +0.1% 979.21 KB 979.88 KB 217.08 KB 217.26 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10 KB 10 KB 3.36 KB 3.36 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 154.48 KB 154.48 KB 38.97 KB 38.97 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% 0.0% 127.45 KB 127.45 KB 40.62 KB 40.62 KB UMD_PROFILING
ReactDOMForked-prod.js 0.0% 0.0% 408.63 KB 408.63 KB 73.95 KB 73.95 KB FB_WWW_PROD
ReactDOMServer-prod.js 0.0% 0.0% 52.56 KB 52.56 KB 12.68 KB 12.68 KB FB_WWW_PROD
react-dom.development.js +0.1% +0.1% 890.47 KB 891.15 KB 201.49 KB 201.68 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 53.21 KB 53.21 KB 13.65 KB 13.65 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 123.78 KB 123.78 KB 38.61 KB 38.62 KB NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 9.75 KB 9.75 KB 3.25 KB 3.26 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-profiling.js 0.0% 0.0% 282.34 KB 282.34 KB 48.77 KB 48.77 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% 0.0% 262.91 KB 262.91 KB 45.08 KB 45.08 KB RN_OSS_PROD
ReactFabric-profiling.js 0.0% 0.0% 274.33 KB 274.33 KB 47.26 KB 47.26 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 639.61 KB 640.29 KB 136.58 KB 136.77 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 0.0% 263.06 KB 263.06 KB 45.12 KB 45.12 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% +0.1% 653.41 KB 654.08 KB 140.26 KB 140.46 KB RN_OSS_DEV
ReactFabric-profiling.js 0.0% 0.0% 274.47 KB 274.47 KB 47.29 KB 47.29 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 657.89 KB 658.57 KB 141.02 KB 141.21 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% 0.0% 271.07 KB 271.07 KB 46.63 KB 46.63 KB RN_FB_PROD
ReactFabric-dev.js +0.1% +0.1% 635.12 KB 635.79 KB 135.84 KB 136.03 KB RN_OSS_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-reflection.development.js 0.0% 0.0% 16.23 KB 16.23 KB 4.92 KB 4.92 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.58 KB 2.58 KB 1.09 KB 1.09 KB NODE_PROD
react-reconciler.development.js +0.1% +0.1% 597.84 KB 598.52 KB 126.07 KB 126.24 KB NODE_DEV

Size changes (experimental)

Generated by 🚫 dangerJS against 4c6470c

Some of our internal reconciler types have leaked into other packages.
Usually, these types are treated as opaque; we don't read and write
to its fields. This is good.

However, the type is often passed back to a reconciler method. For
example, React DOM creates a FiberRoot with `createContainer`, then
passes that root to `updateContainer`. It doesn't do anything with the
root except pass it through, but because `updateContainer` expects a
full FiberRoot, React DOM is still coupled to all its fields.

I don't know if there's an idiomatic way to handle this in Flow. Opaque
types are simlar, but those only work within a single file. AFAIK,
there's no way to use a package as the boundary for opaqueness.

The immediate problem this presents is that the reconciler refactor will
involve changes to our internal data structures. I don't want to have to
fork every single package that happens to pass through a Fiber or
FiberRoot, or access any one of its fields. So my current plan is to
share the same Flow type across both forks. The shared type will be a
superset of each implementation's type, e.g. Fiber will have both an
`expirationTime` field and a `lanes` field. The implementations will
diverge, but not the types.

To do this, I lifted the type definitions into a separate module.
All changes in this commit were generated by the following commands.

Copy each module that ends with `.old` to a new file that ends
with `.new`:

```sh
for f in packages/react-reconciler/src/*.old.js; do cp "$f" "$(echo "$f" | sed s/\.old/\.new/)"; done
```

Then transform the internal imports:

```sh
grep -rl --include="*.new.js" '.old' packages/react-reconciler/src/| xargs sed -i '' "s/\.old\'/\.new\'/g"
```
Updates Rollup, Jest, and Flow configuration to point to the new
entry points.
@acdlite acdlite requested a review from sebmarkbage April 9, 2020 07:27
@acdlite acdlite marked this pull request as ready for review April 9, 2020 07:27
@acdlite
Copy link
Collaborator Author

acdlite commented Apr 9, 2020

I'm going to land this while everyone is sleeping 😆

Normally I wouldn't do this but I'm making an exception since this affects such a large surface area and landing this in the middle of the day would be pretty churny / annoying to rebase.

More rationalization: none of the implementation has changed, only infra stuff and shuffling of types.

@acdlite acdlite merged commit 4c6470c into facebook:master Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants