GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Flight] Add support for Module References in transport protocol by sebmarkbage · Pull Request #20121 · react/react

Conversation

@sebmarkbage

@sebmarkbage sebmarkbage commented Oct 29, 2020

Copy link
Copy Markdown
Contributor

This is the first in a series of refactors. It adds a first-class type of row value for modules. This was always the idea since they can be preloaded earlier if they're special cased in the stream.

It also accepts a "Module Reference" object anywhere to be serialized in the protocol. This includes the type position of JSX. This is now how client components are defined.

These objects need a non-JSON serializable brand check like symbol check or instanceof. However, React doesn't actually define what kind of object it is. The host environment, i.e. bundler, does. So for the Relay www integration we use JSResource. For the webpack one I temporarily use a react symbol but it should really be something else like an AssetReference object.

All these has to now be allowlisted in isValidElementTypes for every possible bundler environment.

Some follow ups:

  • Dedupe the module reference if it occurs multiple times in a request.
  • Currently the modules just resolve into their value on the client. They should probably resolve into a module reference there instead but then React DOM needs to be made aware of them. We could also resolve them to generic React.lazy values. At least in the element position. This is important because otherwise we end up suspending while resolving the parent rather than when we render the element.
  • Make server components that suspend able to lazily resolve on the client by making the element itself a React.lazy value. Only blocks currently have the ability to progressively reveal.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

edvinerikson and Mathspy reacted with rocket emoji NE-SmallTown reacted with eyes emoji
All reactions
  • 🚀 2 reactions
  • 👀 1 reaction
@sebmarkbage
sebmarkbage requested review from gaearon and lunaruan October 29, 2020 03:57
@facebook-github-bot facebook-github-bot added the CLA Signed label Oct 29, 2020
@codesandbox-ci

codesandbox-ci Bot commented Oct 29, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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 8e54638:

Sandbox Source
React Configuration
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sizebot

sizebot commented Oct 29, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Details of bundled changes.

Comparing: 343d7a4...8e54638

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-jsx-runtime.development.js +1.1% +1.3% 37.47 KB 37.89 KB 10.77 KB 10.91 KB NODE_DEV
react.development.js +0.4% +0.6% 112.42 KB 112.86 KB 27.23 KB 27.38 KB UMD_DEV
react-jsx-runtime.production.min.js 0.0% 🔺+0.2% 984 B 984 B 614 B 615 B NODE_PROD
react-unstable-cache.development.js 0.0% +0.2% 1.05 KB 1.05 KB 588 B 589 B NODE_DEV
React-dev.js +0.5% +0.8% 88.99 KB 89.42 KB 21.17 KB 21.33 KB RN_FB_DEV
react-unstable-cache.profiling.min.js 0.0% +0.2% 866 B 866 B 562 B 563 B NODE_PROFILING
react-jsx-dev-runtime.development.js +1.1% +1.3% 36.89 KB 37.31 KB 10.6 KB 10.74 KB NODE_DEV
react-jsx-dev-runtime.production.min.js 0.0% 🔺+0.6% 478 B 478 B 330 B 332 B NODE_PROD
react-jsx-dev-runtime.profiling.min.js 0.0% +0.3% 477 B 477 B 330 B 331 B NODE_PROFILING
JSXDEVRuntime-dev.js +1.1% +1.3% 39.91 KB 40.34 KB 11.1 KB 11.25 KB FB_WWW_DEV
react.production.min.js 0.0% 0.0% 12.29 KB 12.29 KB 4.79 KB 4.79 KB UMD_PROD
react-jsx-runtime.profiling.min.js 0.0% +0.2% 983 B 983 B 614 B 615 B NODE_PROFILING
react.development.js +0.6% +0.7% 74.25 KB 74.67 KB 19.67 KB 19.81 KB NODE_DEV
react.production.min.js 0.0% 0.0% 7.49 KB 7.49 KB 2.95 KB 2.95 KB NODE_PROD
JSXDEVRuntime-dev.js +1.4% +1.6% 31.82 KB 32.25 KB 8.99 KB 9.13 KB RN_FB_DEV
React-dev.js +0.4% +0.6% 96.84 KB 97.27 KB 23.41 KB 23.54 KB FB_WWW_DEV
React-prod.js 0.0% 0.0% 16.87 KB 16.87 KB 4.37 KB 4.37 KB FB_WWW_PROD
React-profiling.js 0.0% 0.0% 16.87 KB 16.87 KB 4.37 KB 4.37 KB FB_WWW_PROFILING
JSXRuntime-dev.js +1.3% +1.6% 32.4 KB 32.83 KB 9.16 KB 9.3 KB RN_FB_DEV

react-transport-dom-relay

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFlightDOMRelayServer-dev.js +7.2% +5.7% 23.35 KB 25.04 KB 6.1 KB 6.45 KB FB_WWW_DEV
ReactFlightDOMRelayServer-prod.js 🔺+7.0% 🔺+3.7% 13.93 KB 14.91 KB 3.74 KB 3.88 KB FB_WWW_PROD
ReactFlightDOMRelayClient-dev.js +10.5% +4.4% 10.56 KB 11.67 KB 3.31 KB 3.46 KB FB_WWW_DEV
ReactFlightDOMRelayClient-prod.js 🔺+9.0% 🔺+2.6% 4.89 KB 5.33 KB 1.56 KB 1.6 KB FB_WWW_PROD

react-is

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactIs-dev.js +4.9% +7.2% 8.8 KB 9.23 KB 2.32 KB 2.49 KB FB_WWW_DEV
ReactIs-prod.js 🔺+4.0% 🔺+4.9% 5.49 KB 5.7 KB 1.35 KB 1.42 KB FB_WWW_PROD
react-is.development.js +5.4% +8.3% 7.97 KB 8.4 KB 2.05 KB 2.22 KB UMD_DEV
react-is.production.min.js 🔺+4.9% 🔺+4.5% 2.32 KB 2.44 KB 974 B 1018 B UMD_PROD
react-is.development.js +5.6% +8.9% 7.41 KB 7.83 KB 1.97 KB 2.15 KB NODE_DEV
react-is.production.min.js 🔺+4.9% 🔺+4.9% 2.31 KB 2.43 KB 935 B 981 B NODE_PROD

react-transport-dom-webpack

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-transport-dom-webpack-server-runtime.development.js 0.0% +0.1% 2.99 KB 2.99 KB 1.07 KB 1.07 KB NODE_DEV
react-transport-dom-webpack-server-runtime.production.min.js 0.0% 🔺+0.3% 513 B 513 B 350 B 351 B NODE_PROD
react-transport-dom-webpack.development.js +8.4% +3.9% 16.78 KB 18.19 KB 4.81 KB 5 KB UMD_DEV
react-transport-dom-webpack.production.min.js 🔺+8.7% 🔺+5.9% 3.69 KB 4.01 KB 1.71 KB 1.81 KB UMD_PROD
react-transport-dom-webpack.development.js +8.5% +4.1% 15.64 KB 16.97 KB 4.69 KB 4.88 KB NODE_DEV
react-transport-dom-webpack.production.min.js 🔺+9.2% 🔺+6.6% 3.49 KB 3.81 KB 1.61 KB 1.71 KB NODE_PROD
react-transport-dom-webpack-server.node.development.js +6.3% +4.6% 23.35 KB 24.82 KB 6.44 KB 6.73 KB NODE_DEV
react-transport-dom-webpack-server.browser.development.js +6.4% +4.9% 23.91 KB 25.45 KB 6.29 KB 6.6 KB UMD_DEV
react-transport-dom-webpack-server.node.production.min.js 🔺+7.4% 🔺+4.8% 6 KB 6.44 KB 2.54 KB 2.66 KB NODE_PROD
react-transport-dom-webpack-server.browser.production.min.js 🔺+7.2% 🔺+4.6% 6.03 KB 6.47 KB 2.59 KB 2.71 KB UMD_PROD
react-transport-dom-webpack-server.browser.development.js +6.5% +4.8% 22.41 KB 23.88 KB 6.17 KB 6.47 KB NODE_DEV
react-transport-dom-webpack-plugin.js 0.0% +0.3% 437 B 437 B 298 B 299 B NODE_ES2015
react-transport-dom-webpack-server.browser.production.min.js 🔺+7.4% 🔺+5.0% 5.83 KB 6.26 KB 2.51 KB 2.64 KB NODE_PROD

react-client

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-client-flight.development.js +9.8% +4.6% 13.61 KB 14.95 KB 4.18 KB 4.37 KB NODE_DEV
react-client-flight.production.min.js 🔺+9.2% 🔺+5.9% 3.11 KB 3.4 KB 1.46 KB 1.54 KB NODE_PROD

react-server

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-server-flight-server-runtime.development.js 0.0% +0.1% 2.98 KB 2.98 KB 1.06 KB 1.06 KB NODE_DEV
react-server-flight.development.js +6.0% +4.3% 22.94 KB 24.31 KB 6.32 KB 6.59 KB NODE_DEV
react-server-flight.production.min.js 🔺+6.5% 🔺+3.9% 6.11 KB 6.51 KB 2.6 KB 2.7 KB NODE_PROD
react-server.development.js 0.0% +0.1% 5.45 KB 5.45 KB 1.73 KB 1.73 KB NODE_DEV
react-server.production.min.js 0.0% 🔺+0.2% 1.16 KB 1.16 KB 650 B 651 B NODE_PROD

React: size: 0.0%, gzip: 0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 8e54638

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sizebot

sizebot commented Oct 29, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Details of bundled changes.

Comparing: 343d7a4...8e54638

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-jsx-runtime.development.js +1.1% +1.3% 37.46 KB 37.88 KB 10.77 KB 10.91 KB NODE_DEV
react.development.js +0.4% +0.5% 108.45 KB 108.88 KB 26.5 KB 26.63 KB UMD_DEV
react-jsx-runtime.production.min.js 0.0% 🔺+0.2% 971 B 971 B 606 B 607 B NODE_PROD
React-dev.js +0.5% +0.8% 89.99 KB 90.42 KB 21.4 KB 21.56 KB RN_FB_DEV
React-prod.js 0.0% 0.0% 17.27 KB 17.27 KB 4.58 KB 4.58 KB RN_FB_PROD
React-profiling.js 0.0% 0.0% 17.27 KB 17.27 KB 4.58 KB 4.58 KB RN_FB_PROFILING
react-jsx-dev-runtime.development.js +1.1% +1.4% 36.88 KB 37.29 KB 10.6 KB 10.74 KB NODE_DEV
react-jsx-dev-runtime.production.min.js 0.0% 🔺+0.3% 465 B 465 B 322 B 323 B NODE_PROD
react-jsx-dev-runtime.profiling.min.js 0.0% +0.3% 464 B 464 B 321 B 322 B NODE_PROFILING
JSXDEVRuntime-dev.js +1.1% +1.3% 39.91 KB 40.34 KB 11.1 KB 11.25 KB FB_WWW_DEV
react.production.min.js 0.0% 0.0% 11.19 KB 11.19 KB 4.48 KB 4.48 KB UMD_PROD
react-jsx-runtime.profiling.min.js 0.0% +0.2% 970 B 970 B 606 B 607 B NODE_PROFILING
react.profiling.min.js 0.0% +0.1% 14.7 KB 14.7 KB 5.56 KB 5.56 KB UMD_PROFILING
react.development.js +0.6% +0.8% 70.47 KB 70.89 KB 18.97 KB 19.11 KB NODE_DEV
JSXDEVRuntime-dev.js +1.4% +1.6% 31.82 KB 32.25 KB 8.99 KB 9.13 KB RN_FB_DEV
React-dev.js +0.4% +0.6% 97.84 KB 98.27 KB 23.63 KB 23.77 KB FB_WWW_DEV
React-prod.js 0.0% 0.0% 17.02 KB 17.02 KB 4.41 KB 4.41 KB FB_WWW_PROD
React-profiling.js 0.0% 0.0% 17.02 KB 17.02 KB 4.41 KB 4.41 KB FB_WWW_PROFILING
JSXRuntime-dev.js +1.3% +1.6% 32.4 KB 32.83 KB 9.16 KB 9.3 KB RN_FB_DEV

react-transport-dom-relay

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFlightDOMRelayServer-dev.js +7.2% +5.7% 23.35 KB 25.04 KB 6.1 KB 6.45 KB FB_WWW_DEV
ReactFlightDOMRelayServer-prod.js 🔺+7.0% 🔺+3.7% 13.93 KB 14.91 KB 3.74 KB 3.88 KB FB_WWW_PROD
ReactFlightDOMRelayClient-dev.js +10.5% +4.4% 10.56 KB 11.67 KB 3.31 KB 3.46 KB FB_WWW_DEV
ReactFlightDOMRelayClient-prod.js 🔺+9.0% 🔺+2.6% 4.89 KB 5.33 KB 1.56 KB 1.6 KB FB_WWW_PROD

react-is

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactIs-dev.js +4.9% +7.2% 8.8 KB 9.23 KB 2.32 KB 2.49 KB FB_WWW_DEV
ReactIs-prod.js 🔺+4.0% 🔺+4.9% 5.49 KB 5.7 KB 1.35 KB 1.42 KB FB_WWW_PROD
react-is.development.js +5.4% +8.4% 7.96 KB 8.39 KB 2.04 KB 2.22 KB UMD_DEV
react-is.production.min.js 🔺+4.9% 🔺+4.6% 2.31 KB 2.42 KB 966 B 1010 B UMD_PROD
react-is.development.js +5.6% +8.9% 7.4 KB 7.82 KB 1.97 KB 2.14 KB NODE_DEV
react-is.production.min.js 🔺+5.0% 🔺+5.0% 2.3 KB 2.42 KB 925 B 971 B NODE_PROD

react-transport-dom-webpack

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-transport-dom-webpack-server-runtime.development.js 0.0% +0.2% 2.98 KB 2.98 KB 1.07 KB 1.07 KB NODE_DEV
react-transport-dom-webpack-server-runtime.production.min.js 0.0% 🔺+0.3% 500 B 500 B 341 B 342 B NODE_PROD
react-transport-dom-webpack.development.js +8.4% +3.9% 16.77 KB 18.18 KB 4.8 KB 4.99 KB UMD_DEV
react-transport-dom-webpack.production.min.js 🔺+8.8% 🔺+5.9% 3.68 KB 4 KB 1.7 KB 1.8 KB UMD_PROD
react-transport-dom-webpack.development.js +8.5% +4.1% 15.63 KB 16.96 KB 4.68 KB 4.87 KB NODE_DEV
react-transport-dom-webpack.production.min.js 🔺+9.2% 🔺+6.5% 3.47 KB 3.8 KB 1.6 KB 1.7 KB NODE_PROD
react-transport-dom-webpack-server.node.development.js +6.3% +4.6% 23.34 KB 24.8 KB 6.43 KB 6.73 KB NODE_DEV
react-transport-dom-webpack-server.browser.development.js +6.4% +4.9% 23.9 KB 25.44 KB 6.29 KB 6.59 KB UMD_DEV
react-transport-dom-webpack-server.node.production.min.js 🔺+7.4% 🔺+4.9% 5.99 KB 6.43 KB 2.53 KB 2.65 KB NODE_PROD
react-transport-dom-webpack-server.browser.production.min.js 🔺+7.2% 🔺+4.6% 6.02 KB 6.45 KB 2.59 KB 2.71 KB UMD_PROD
react-transport-dom-webpack-server.browser.development.js +6.5% +4.8% 22.4 KB 23.86 KB 6.16 KB 6.46 KB NODE_DEV
react-transport-dom-webpack-plugin.js 0.0% +0.3% 424 B 424 B 289 B 290 B NODE_ES2015
react-transport-dom-webpack-server.browser.production.min.js 🔺+7.4% 🔺+5.0% 5.81 KB 6.25 KB 2.5 KB 2.63 KB NODE_PROD

react-client

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-client-flight.development.js +9.8% +4.5% 13.6 KB 14.93 KB 4.18 KB 4.37 KB NODE_DEV
react-client-flight.production.min.js 🔺+9.2% 🔺+6.0% 3.1 KB 3.38 KB 1.45 KB 1.54 KB NODE_PROD

react-server

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-server-flight-server-runtime.development.js 0.0% +0.1% 2.97 KB 2.97 KB 1.05 KB 1.06 KB NODE_DEV
react-server-flight-server-runtime.production.min.js 0.0% 🔺+0.3% 492 B 492 B 330 B 331 B NODE_PROD
react-server-flight.development.js +6.0% +4.3% 22.93 KB 24.3 KB 6.31 KB 6.58 KB NODE_DEV
react-server-flight.production.min.js 🔺+6.5% 🔺+3.9% 6.1 KB 6.5 KB 2.59 KB 2.7 KB NODE_PROD
react-server.development.js 0.0% +0.1% 5.43 KB 5.43 KB 1.72 KB 1.72 KB NODE_DEV
react-server.production.min.js 0.0% 🔺+0.2% 1.15 KB 1.15 KB 641 B 642 B NODE_PROD

React: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 8e54638

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaearon
gaearon approved these changes Oct 29, 2020
View reviewed changes
Comment thread packages/shared/isValidElementType.js Outdated
// we don't know which Flight build this will end up being used
// with.
type.$$typeof === REACT_MODULE_REFERENCE ||
type._moduleId !== undefined ||

@gaearon gaearon Oct 29, 2020

Copy link
Copy Markdown
Collaborator

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 don't really get this. Why can't we use the brand check? Why can't different systems agree on the Symbol to use if they have to agree on the field name anyway?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sebmarkbage sebmarkbage Oct 29, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

They don’t have to agree on either. For now it just has to match one or the other. The field check is just because I can’t require JSResourceReference in other environments but it should really be an instanceof check. We just have to add all possible checks here. If this was a true private field we couldn’t check the field neither. That might even mean that we have to relax it to accept all objects.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaearon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@sebmarkbage sebmarkbage Oct 29, 2020

Copy link
Copy Markdown
Contributor Author

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.

Ugh. This didn't even work because we obscure underscore prefixed properties.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaearon reacted with laugh emoji
All reactions
  • 😄 1 reaction
@sebmarkbage

sebmarkbage commented Oct 29, 2020

Copy link
Copy Markdown
Contributor Author

I don't really like this approach because as it's currently set up, this will yield a different value on the output than the input of serialization.

<Foo moduleRef={JSResource(...)} /> and then the receiver will get the actual resolved value. let fn: ActualValue = props.moduleRef;.

So input is ModuleRef<T> and output is T. This makes the types not just automatically line up even though other than that, it's very convenient because you don't have to think about suspending and stuff. You just get the actual value.

This is actually fine if we stick to the automatic conversion of import statements because we can pretend to TypeScript that it's the real value, but not for the longer term asset reference or FB variant which is an explicit reference object.

Another approach would be to send T by registering a value on the server in a WeakMap and serialize that. But then you actually have to load that module on the server just to get a reference that you're not going to use. So I think that's a no-go.

I think a better approach would be input ModuleRef<T> and output ModuleRef<T>. However, React DOM doesn't know what to do with a ModuleRef yet. That's fine because we can convert it to Lazy<T> when it's inside React Elements as a special case for now.

In general, the reason it's hard to just use a ModuleRef<T> is because you have to suspend to get a value out. Since native APIs don't allow for a way to do this without a tick, it's bad for perf and the Flight implementation has built-in caches to deal with that. So you'd still need something like Lazy that redirects to the specific implementation that knows how to read from it in a Suspense friendly way.

Another approach would be to treat all references as T | ModuleRef<T> so you have to handle both cases but in practice it would actually just be T.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sebmarkbage

sebmarkbage commented Oct 29, 2020

Copy link
Copy Markdown
Contributor Author

I guess since there are two different approaches: 1) Explicit call to get a reference. 2) A reference is automatically created by the compiler. There really need to be two different wrapper objects that yield the different semantics.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sebmarkbage added 10 commits October 29, 2020 20:36
@sebmarkbage
Refactor Flight to require a module reference to be brand checked
6379b5a
This exposes a host environment (bundler) specific hook to check if an
object is a module reference. This will be used so that they can be passed
directly into Flight without needing additional wrapper objects.
@sebmarkbage
Emit module references as a special type of value
65741fe
We already have JSON and errors as special types of "rows". This encodes
module references as a special type of row value. This was always the
intention because it allows those values to be emitted first in the stream
so that as a large models stream down, we can start preloading as early
as possible.

We preload the module when they resolve but we lazily require them as they
are referenced.
@sebmarkbage
Emit module references where ever they occur
1bac86d
This emits module references where ever they occur. In blocks or even
directly in elements.
@sebmarkbage
Don't special case the root row
cfb3030
I originally did this so that a simple stream is also just plain JSON.

However, since we might want to emit things like modules before the root
module in the stream, this gets unnecessarily complicated. We could add
this back as a special case if it's the first byte written but meh.
@sebmarkbage
Update the protocol
0a3355d
@sebmarkbage
Add test for using a module reference as a client component
1a6972a
@sebmarkbage
Relax element type check
0f1c236
Since Flight now accepts a module reference as returned by any bundler
system, depending on the renderer running. We need to drastically relax
the check to include all of them. We can add more as we discover them.
@sebmarkbage
Move flow annotation
dd31dfa
Seems like our compiler is not happy with stripping this.
@sebmarkbage
Some bookkeeping bug
160510d
@sebmarkbage
Can't use the private field to check
8e54638
@sebmarkbage
sebmarkbage force-pushed the refactorflight branch from 2aaf7a9 to 8e54638 Compare October 30, 2020 00:36
@sebmarkbage
sebmarkbage merged commit ffd8423 into react:master Oct 30, 2020
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 9, 2020
@sebmarkbage @facebook-github-bot
React Native sync for revisions 4e5d7fa...454c221
69ade59
Summary:
Base sync before adding Flight files.

This sync includes the following changes:
- **[454c221](react/react@454c2211c )**: Refactor SchedulerHostConfigs ([#20025](react/react#20025)) //<Ricky>//
- **[56e9fee](react/react@56e9feead )**: Remove Blocks ([#20138](react/react#20138)) //<Sebastian Markbåge>//
- **[3fbd47b](react/react@3fbd47b86 )**: Serialize pending server components by reference (lazy component) ([#20137](react/react#20137)) //<Sebastian Markbåge>//
- **[930ce7c](react/react@930ce7c15 )**: Allow values to be encoded by "reference" to a value rather than the value itself ([#20136](react/react#20136)) //<Sebastian Markbåge>//
- **[39eb6d1](react/react@39eb6d176 )**: Rename ([#20134](react/react#20134)) //<Sebastian Markbåge>//
- **[ffd8423](react/react@ffd842335 )**: [Flight] Add support for Module References in transport protocol ([#20121](react/react#20121)) //<Sebastian Markbåge>//
- **[343d7a4](react/react@343d7a4a7 )**: Fast Refresh: Don't block DevTools commit hook ([#20129](react/react#20129)) //<Brian Vaughn>//
- **[779a472](react/react@779a472b0 )**: Prevent inlining into recursive commit functions ([#20105](react/react#20105)) //<Andrew Clark>//
- **[25b18d3](react/react@25b18d31c )**: Traverse commit phase effects iteratively ([#20094](react/react#20094)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 4e5d7fa...454c221

Reviewed By: rickhanlonii

Differential Revision: D24698701

fbshipit-source-id: dfaf692b1051150355dece1657764a484b7ae603
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
@sebmarkbage @koto
[Flight] Add support for Module References in transport protocol (rea…
5c2adda
…ct#20121)

* Refactor Flight to require a module reference to be brand checked

This exposes a host environment (bundler) specific hook to check if an
object is a module reference. This will be used so that they can be passed
directly into Flight without needing additional wrapper objects.

* Emit module references as a special type of value

We already have JSON and errors as special types of "rows". This encodes
module references as a special type of row value. This was always the
intention because it allows those values to be emitted first in the stream
so that as a large models stream down, we can start preloading as early
as possible.

We preload the module when they resolve but we lazily require them as they
are referenced.

* Emit module references where ever they occur

This emits module references where ever they occur. In blocks or even
directly in elements.

* Don't special case the root row

I originally did this so that a simple stream is also just plain JSON.

However, since we might want to emit things like modules before the root
module in the stream, this gets unnecessarily complicated. We could add
this back as a special case if it's the first byte written but meh.

* Update the protocol

* Add test for using a module reference as a client component

* Relax element type check

Since Flight now accepts a module reference as returned by any bundler
system, depending on the renderer running. We need to drastically relax
the check to include all of them. We can add more as we discover them.

* Move flow annotation

Seems like our compiler is not happy with stripping this.

* Some bookkeeping bug

* Can't use the private field to check
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@sebmarkbage
[Flight] Add support for Module References in transport protocol (rea…
40bb7ed
…ct#20121)

* Refactor Flight to require a module reference to be brand checked

This exposes a host environment (bundler) specific hook to check if an
object is a module reference. This will be used so that they can be passed
directly into Flight without needing additional wrapper objects.

* Emit module references as a special type of value

We already have JSON and errors as special types of "rows". This encodes
module references as a special type of row value. This was always the
intention because it allows those values to be emitted first in the stream
so that as a large models stream down, we can start preloading as early
as possible.

We preload the module when they resolve but we lazily require them as they
are referenced.

* Emit module references where ever they occur

This emits module references where ever they occur. In blocks or even
directly in elements.

* Don't special case the root row

I originally did this so that a simple stream is also just plain JSON.

However, since we might want to emit things like modules before the root
module in the stream, this gets unnecessarily complicated. We could add
this back as a special case if it's the first byte written but meh.

* Update the protocol

* Add test for using a module reference as a client component

* Relax element type check

Since Flight now accepts a module reference as returned by any bundler
system, depending on the renderer running. We need to drastically relax
the check to include all of them. We can add more as we discover them.

* Move flow annotation

Seems like our compiler is not happy with stripping this.

* Some bookkeeping bug

* Can't use the private field to check
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
[Flight] Add support for Module References in transport protocol (rea…
131c1a2
…ct#20121)

* Refactor Flight to require a module reference to be brand checked

This exposes a host environment (bundler) specific hook to check if an
object is a module reference. This will be used so that they can be passed
directly into Flight without needing additional wrapper objects.

* Emit module references as a special type of value

We already have JSON and errors as special types of "rows". This encodes
module references as a special type of row value. This was always the
intention because it allows those values to be emitted first in the stream
so that as a large models stream down, we can start preloading as early
as possible.

We preload the module when they resolve but we lazily require them as they
are referenced.

* Emit module references where ever they occur

This emits module references where ever they occur. In blocks or even
directly in elements.

* Don't special case the root row

I originally did this so that a simple stream is also just plain JSON.

However, since we might want to emit things like modules before the root
module in the stream, this gets unnecessarily complicated. We could add
this back as a special case if it's the first byte written but meh.

* Update the protocol

* Add test for using a module reference as a client component

* Relax element type check

Since Flight now accepts a module reference as returned by any bundler
system, depending on the renderer running. We need to drastically relax
the check to include all of them. We can add more as we discover them.

* Move flow annotation

Seems like our compiler is not happy with stripping this.

* Some bookkeeping bug

* Can't use the private field to check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gaearon gaearon gaearon approved these changes
@lunaruan lunaruan Awaiting requested review from lunaruan

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@sebmarkbage @sizebot @gaearon @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.