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

[Flight] Chunks API #17398

Merged
merged 9 commits into from
Dec 18, 2019
Merged

[Flight] Chunks API #17398

merged 9 commits into from
Dec 18, 2019

Conversation

sebmarkbage
Copy link
Collaborator

This is a very early experiment. We just need something to play with.

This is a new core API but it's not really meant to be used without Flight. Instead Flight will produce these "chunks" from its payload. The primary purpose of this in core is to ensure the reconciler can update the same component instance with new data.

It can be used without Flight by running it in the same environment and it works fine. That is a nice property because a) it means you can get started running this code in a client-only environment and debug in browser. b) it describes the semantics in a standalone way which is how the type system thinks about it, so it's nice to be able to think about it this way.

This implementation doesn't support Context. Exposing React's context wouldn't be the same semantics as with Flight so it's not super easy and requires more code to actually support Context in this mode. That's unfortunate.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 18, 2019

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 3062dfc:

Sandbox Source
serverless-rain-z3mbr Configuration

@sizebot
Copy link

sizebot commented Nov 18, 2019

Details of bundled changes.

Comparing: 4c27037...3062dfc

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +1.7% +1.1% 110.42 KB 112.27 KB 28.41 KB 28.73 KB UMD_DEV
react.production.min.js 🔺+0.2% 🔺+0.1% 12.3 KB 12.33 KB 4.83 KB 4.84 KB UMD_PROD
react.profiling.min.js +0.2% +0.1% 15.82 KB 15.85 KB 5.94 KB 5.94 KB UMD_PROFILING
react.development.js +2.6% +1.8% 69.93 KB 71.78 KB 18.72 KB 19.05 KB NODE_DEV
react.production.min.js 🔺+0.4% 🔺+0.1% 6.51 KB 6.54 KB 2.71 KB 2.72 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js +0.6% +0.4% 729.98 KB 734.61 KB 154.83 KB 155.42 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.3% 🔺+0.2% 264.72 KB 265.54 KB 45.63 KB 45.71 KB RN_OSS_PROD
ReactNativeRenderer-dev.js +0.6% +0.4% 739.41 KB 744.04 KB 157.07 KB 157.67 KB RN_OSS_DEV
ReactFabric-profiling.js +0.3% +0.2% 275.85 KB 276.67 KB 47.75 KB 47.83 KB RN_OSS_PROFILING
ReactNativeRenderer-prod.js 🔺+0.3% 🔺+0.2% 272.32 KB 273.14 KB 46.89 KB 46.98 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.3% +0.2% 283.49 KB 284.31 KB 49.03 KB 49.12 KB RN_OSS_PROFILING

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.production.min.js 🔺+0.3% 🔺+0.2% 71.85 KB 72.04 KB 21.18 KB 21.21 KB NODE_PROD
react-reconciler.development.js +0.7% +0.4% 598.41 KB 602.83 KB 126.89 KB 127.44 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.3% 🔺+0.2% 71.83 KB 72.03 KB 21.17 KB 21.21 KB NODE_PROD
react-reconciler-reflection.development.js +0.9% +0.5% 19.09 KB 19.25 KB 6.29 KB 6.33 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% -0.1% 2.85 KB 2.85 KB 1.24 KB 1.23 KB NODE_PROD
react-reconciler-persistent.development.js +0.7% +0.4% 595.88 KB 600.28 KB 125.79 KB 126.33 KB NODE_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.production.min.js 🔺+0.3% 🔺+0.2% 19.86 KB 19.92 KB 7.38 KB 7.39 KB NODE_PROD
react-dom-test-utils.development.js 0.0% 0.0% 52.73 KB 52.76 KB 14.98 KB 14.99 KB NODE_DEV
react-dom.production.min.js 🔺+0.2% 🔺+0.1% 115.63 KB 115.81 KB 37.32 KB 37.37 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.59 KB 60.59 KB 15.99 KB 15.99 KB NODE_DEV
react-dom.profiling.min.js +0.2% +0.1% 119.26 KB 119.45 KB 38.49 KB 38.52 KB UMD_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 9.96 KB 9.96 KB 3.37 KB 3.36 KB NODE_PROD
react-dom.development.js +0.5% +0.3% 941.11 KB 945.53 KB 213.17 KB 213.71 KB NODE_DEV
react-dom.production.min.js 🔺+0.2% 🔺+0.1% 115.7 KB 115.88 KB 36.66 KB 36.68 KB NODE_PROD
react-dom.profiling.min.js +0.2% +0.1% 119.46 KB 119.64 KB 37.78 KB 37.82 KB NODE_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.87 KB 3.87 KB 1.54 KB 1.54 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.2 KB 1.2 KB 703 B 701 B UMD_PROD
react-dom-server.browser.development.js +0.1% +0.1% 137.52 KB 137.69 KB 36.57 KB 36.61 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+0.3% 🔺+0.2% 19.93 KB 19.99 KB 7.38 KB 7.4 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.7 KB 3.7 KB 1.5 KB 1.49 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 54.46 KB 54.48 KB 15.31 KB 15.31 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.04 KB 1.04 KB 634 B 632 B NODE_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 11.17 KB 11.17 KB 4.14 KB 4.14 KB UMD_PROD
react-dom-server.browser.development.js +0.1% +0.1% 133.46 KB 133.62 KB 35.55 KB 35.58 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.94 KB 10.94 KB 4.09 KB 4.08 KB NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 4.4 KB 4.4 KB 1.64 KB 1.64 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.89 KB 60.89 KB 16.07 KB 16.06 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.2 KB 1.2 KB 690 B 688 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 10.22 KB 10.22 KB 3.47 KB 3.46 KB UMD_PROD
react-dom-server.node.development.js +0.1% +0.1% 134.57 KB 134.73 KB 35.78 KB 35.81 KB NODE_DEV
react-dom.development.js +0.5% +0.3% 947.04 KB 951.47 KB 214.82 KB 215.36 KB UMD_DEV
react-dom-server.node.production.min.js 🔺+0.3% 🔺+0.2% 20.27 KB 20.33 KB 7.53 KB 7.55 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.production.min.js 🔺+0.2% 0.0% 104.13 KB 104.31 KB 31.78 KB 31.79 KB UMD_PROD
react-art.development.js +0.7% +0.4% 666.75 KB 671.14 KB 145.13 KB 145.68 KB UMD_DEV
react-art.development.js +0.7% +0.4% 597.4 KB 601.82 KB 127.73 KB 128.27 KB NODE_DEV
react-art.production.min.js 🔺+0.3% 🔺+0.2% 69.13 KB 69.31 KB 20.92 KB 20.96 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.development.js +0.4% +0.2% 37.67 KB 37.81 KB 9.77 KB 9.8 KB UMD_DEV
react-test-renderer-shallow.production.min.js 🔺+0.5% 🔺+0.4% 11.58 KB 11.64 KB 3.58 KB 3.59 KB UMD_PROD
react-test-renderer-shallow.development.js +0.4% +0.3% 32.21 KB 32.35 KB 8.46 KB 8.49 KB NODE_DEV
react-test-renderer-shallow.production.min.js 🔺+0.5% 🔺+0.5% 11.72 KB 11.78 KB 3.68 KB 3.7 KB NODE_PROD
react-test-renderer.development.js +0.8% +0.4% 611.55 KB 616.17 KB 130.73 KB 131.29 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.4% 🔺+0.1% 71.17 KB 71.46 KB 21.86 KB 21.88 KB UMD_PROD
react-test-renderer.development.js +0.8% +0.4% 606.82 KB 611.43 KB 129.55 KB 130.11 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.4% 🔺+0.2% 70.86 KB 71.15 KB 21.45 KB 21.5 KB NODE_PROD

ReactDOM: size: 🔺+0.2%, gzip: 🔺+0.1%

React: size: 🔺+0.2%, gzip: 🔺+0.1%

Size changes (stable)

Generated by 🚫 dangerJS against 3062dfc

@sizebot
Copy link

sizebot commented Nov 18, 2019

Details of bundled changes.

Comparing: 4c27037...3062dfc

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +1.7% +1.1% 110.44 KB 112.29 KB 28.42 KB 28.73 KB UMD_DEV
react.production.min.js 🔺+1.3% 🔺+0.9% 12.51 KB 12.67 KB 4.9 KB 4.94 KB UMD_PROD
React-prod.js 🔺+1.7% 🔺+1.7% 17.7 KB 18.01 KB 4.61 KB 4.69 KB FB_WWW_PROD
React-profiling.js +1.7% +1.7% 17.7 KB 18.01 KB 4.61 KB 4.69 KB FB_WWW_PROFILING
react.profiling.min.js +1.0% +0.7% 16.03 KB 16.2 KB 6.01 KB 6.05 KB UMD_PROFILING
react.development.js +2.6% +1.8% 69.95 KB 71.8 KB 18.73 KB 19.06 KB NODE_DEV
react.production.min.js 🔺+2.4% 🔺+1.7% 6.8 KB 6.96 KB 2.81 KB 2.86 KB NODE_PROD
React-dev.js +2.9% +1.7% 70.27 KB 72.29 KB 18.1 KB 18.41 KB FB_WWW_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +0.5% +0.4% 122.96 KB 123.63 KB 38.72 KB 38.88 KB NODE_PROFILING
react-dom-server.browser.development.js +0.1% +0.1% 137.55 KB 137.71 KB 36.57 KB 36.61 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+0.3% 🔺+0.2% 20.39 KB 20.45 KB 7.48 KB 7.5 KB UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 54.47 KB 54.5 KB 15.31 KB 15.32 KB UMD_DEV
ReactDOMServer-prod.js 🔺+0.3% 🔺+0.2% 48.86 KB 49 KB 11.16 KB 11.19 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.88 KB 3.88 KB 1.55 KB 1.55 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 11.18 KB 11.18 KB 4.15 KB 4.15 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.21 KB 1.21 KB 711 B 709 B UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 52.75 KB 52.77 KB 14.99 KB 14.99 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.71 KB 3.71 KB 1.5 KB 1.5 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.95 KB 10.95 KB 4.09 KB 4.09 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.05 KB 1.05 KB 642 B 640 B NODE_PROD
react-dom.development.js +0.5% +0.3% 947.06 KB 951.49 KB 214.84 KB 215.38 KB UMD_DEV
react-dom.production.min.js 🔺+0.6% 🔺+0.5% 118.99 KB 119.65 KB 38.3 KB 38.49 KB UMD_PROD
react-dom.profiling.min.js +0.5% +0.6% 122.73 KB 123.39 KB 39.42 KB 39.64 KB UMD_PROFILING
react-dom.development.js +0.5% +0.3% 941.13 KB 945.55 KB 213.19 KB 213.73 KB NODE_DEV
react-dom-server.node.development.js +0.1% +0.1% 134.59 KB 134.76 KB 35.78 KB 35.82 KB NODE_DEV
react-dom.production.min.js 🔺+0.6% 🔺+0.4% 119.08 KB 119.75 KB 37.58 KB 37.75 KB NODE_PROD
react-dom-server.node.production.min.js 🔺+0.3% 🔺+0.2% 20.73 KB 20.79 KB 7.61 KB 7.63 KB NODE_PROD
react-dom-server.browser.development.js +0.1% +0.1% 133.48 KB 133.65 KB 35.55 KB 35.58 KB NODE_DEV
ReactDOM-dev.js +0.5% +0.3% 968.85 KB 973.48 KB 216.04 KB 216.61 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 🔺+0.3% 🔺+0.2% 20.32 KB 20.38 KB 7.46 KB 7.47 KB NODE_PROD
ReactDOM-prod.js 🔺+0.9% 🔺+0.5% 391.47 KB 394.86 KB 71.95 KB 72.29 KB FB_WWW_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.91 KB 60.91 KB 16.07 KB 16.07 KB UMD_DEV
ReactDOM-profiling.js +0.8% +0.5% 402.77 KB 406.15 KB 74.07 KB 74.41 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 10.23 KB 10.23 KB 3.47 KB 3.47 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.61 KB 60.61 KB 16 KB 15.99 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 4.42 KB 4.42 KB 1.65 KB 1.65 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.1% 9.97 KB 9.97 KB 3.37 KB 3.37 KB NODE_PROD
ReactDOMServer-dev.js +0.1% +0.1% 139.21 KB 139.36 KB 35.41 KB 35.43 KB FB_WWW_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.21 KB 1.21 KB 698 B 696 B NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.8% +0.4% 611.58 KB 616.19 KB 130.74 KB 131.3 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.4% 🔺+0.1% 71.19 KB 71.49 KB 21.88 KB 21.9 KB UMD_PROD
react-test-renderer-shallow.development.js +0.4% +0.2% 37.68 KB 37.83 KB 9.78 KB 9.8 KB UMD_DEV
react-test-renderer-shallow.production.min.js 🔺+0.5% 🔺+0.4% 11.6 KB 11.66 KB 3.58 KB 3.6 KB UMD_PROD
react-test-renderer-shallow.development.js +0.4% +0.3% 32.22 KB 32.37 KB 8.47 KB 8.5 KB NODE_DEV
react-test-renderer-shallow.production.min.js 🔺+0.5% 🔺+0.5% 11.73 KB 11.79 KB 3.69 KB 3.71 KB NODE_PROD
react-test-renderer.development.js +0.8% +0.4% 606.85 KB 611.46 KB 129.56 KB 130.12 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.4% 🔺+0.2% 70.88 KB 71.17 KB 21.46 KB 21.52 KB NODE_PROD
ReactShallowRenderer-dev.js +0.4% +0.3% 34.23 KB 34.38 KB 8.43 KB 8.46 KB FB_WWW_DEV
ReactTestRenderer-dev.js +0.8% +0.4% 622.45 KB 627.3 KB 130.32 KB 130.91 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.6% +0.4% 739.43 KB 744.05 KB 157.08 KB 157.68 KB RN_OSS_DEV
ReactFabric-dev.js +0.6% +0.4% 729.99 KB 734.62 KB 154.84 KB 155.42 KB RN_OSS_DEV
ReactNativeRenderer-dev.js +0.6% +0.4% 739.6 KB 744.23 KB 157.17 KB 157.77 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.3% 🔺+0.2% 264.74 KB 265.55 KB 45.63 KB 45.72 KB RN_OSS_PROD
ReactNativeRenderer-prod.js 🔺+0.3% 🔺+0.2% 272.72 KB 273.54 KB 46.97 KB 47.06 KB RN_FB_PROD
ReactFabric-profiling.js +0.3% +0.2% 275.86 KB 276.68 KB 47.76 KB 47.84 KB RN_OSS_PROFILING
ReactNativeRenderer-profiling.js +0.3% +0.2% 283.89 KB 284.71 KB 49.11 KB 49.2 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js 🔺+0.3% 🔺+0.2% 272.33 KB 273.15 KB 46.9 KB 46.99 KB RN_OSS_PROD
ReactFabric-dev.js +0.6% +0.4% 730.17 KB 734.8 KB 154.92 KB 155.51 KB RN_FB_DEV
ReactNativeRenderer-profiling.js +0.3% +0.2% 283.51 KB 284.32 KB 49.04 KB 49.13 KB RN_OSS_PROFILING
ReactFabric-prod.js 🔺+0.3% 🔺+0.2% 265.08 KB 265.9 KB 45.7 KB 45.79 KB RN_FB_PROD
ReactFabric-profiling.js +0.3% +0.2% 276.21 KB 277.03 KB 47.82 KB 47.91 KB RN_FB_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +0.8% +0.5% 611.08 KB 615.7 KB 127.79 KB 128.38 KB FB_WWW_DEV
ReactART-prod.js 🔺+1.5% 🔺+0.8% 232.83 KB 236.22 KB 39.58 KB 39.92 KB FB_WWW_PROD
react-art.development.js +0.7% +0.4% 666.78 KB 671.17 KB 145.14 KB 145.68 KB UMD_DEV
react-art.production.min.js 🔺+0.6% 🔺+0.5% 106.15 KB 106.81 KB 32.33 KB 32.49 KB UMD_PROD
react-art.development.js +0.7% +0.4% 597.42 KB 601.84 KB 127.74 KB 128.28 KB NODE_DEV
react-art.production.min.js 🔺+0.9% 🔺+0.8% 71.11 KB 71.77 KB 21.46 KB 21.64 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js +0.7% +0.4% 595.89 KB 600.29 KB 125.79 KB 126.33 KB NODE_DEV
react-reconciler-reflection.development.js +0.9% +0.5% 19.1 KB 19.27 KB 6.3 KB 6.33 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.3% 🔺+0.2% 71.86 KB 72.05 KB 21.19 KB 21.22 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.1% 2.86 KB 2.86 KB 1.24 KB 1.24 KB NODE_PROD
react-reconciler.development.js +0.7% +0.4% 598.42 KB 602.84 KB 126.89 KB 127.44 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.9% 🔺+0.7% 74.08 KB 74.75 KB 21.75 KB 21.9 KB NODE_PROD

ReactDOM: size: 🔺+0.3%, gzip: 🔺+0.2%

React: size: 🔺+1.3%, gzip: 🔺+0.9%

Size changes (experimental)

Generated by 🚫 dangerJS against 3062dfc

$$typeof: REACT_CHUNK_TYPE,
query: function() {
return query.apply(null, args);
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In Flight, this function will be replaced by one that suspends on the data, as well as as a render that suspends on the code.

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

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

Looks OK overall but the child fiber stuff is fragile and there's a bug. I think we need to ensure we have coverage for every branch we're changing before landing this.

@devknoll
Copy link
Contributor

devknoll commented Nov 27, 2019

QQ: From what I can see, this looks like it would work in legacy mode too, right? If so, is that intentional?

@sebmarkbage sebmarkbage merged commit 7dc9745 into facebook:master Dec 18, 2019
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
* Add feature flags

* Add Chunk type and constructor

* Wire up Chunk support in the reconciler

* Update reconciler to reconcile Chunks against the render method

This allows the query and args to be updated.

* Drop the ref. Chunks cannot have refs anyway.

* Add Chunk checks in more missing cases

* Rename secondArg

* Add test and fix lazy chunks

Not really a supported use case but for consistency I guess.

* Fix fragment test
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.

6 participants