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

[Float] stylesheet hoisting #24886

Closed
wants to merge 7 commits into from
Closed

Conversation

gnoff
Copy link
Collaborator

@gnoff gnoff commented Jul 11, 2022

This is a pared down PR with stylesheet hoisting for Flight / Fizz / Client.

  • Flight support
  • Fizz support
  • Client support
  • Capabilities
    • Can hydrate resources
    • Can hoist resources
    • Can opt out of resource per component
    • Can support all valid props
      • Keying props
      • prop validation
      • Ignorable props
    • Can handle load/error events

Comment on lines +2074 to +2077
if (completedRootSegment !== null) {
if (request.pendingRootTasks === 0) {
// Flush the prelude if it exists
const prelude = request.prelude;
for (i = 0; i < prelude.length; i++) {
// we expect the prelude to be tiny and will ignore backpressure
writeChunk(destination, prelude[i]);
}
prelude.length = 0;

// Flush resources
writeResources(destination, request.resources);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we have a completedRootSegment it is safe to flush the prelude (we should consider barring use of the prelude after the root segment has flushed. This currently can't / doesn't happen but a future change could alter that)

Once we have flushed the prelude we can flush resources and then the segment.

Comment on lines +2095 to +2088
} else {
writeResources(destination, request.resources);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This maybe needs to be tuned up.

At the moment, if we flush before starting work we call writeResources which happens to be empty but we don't actually know that this is safe b/c writeResources might have it's own writable content that isn't related to the number of resources that exist. For now this works by coincidence.

Typically though the flushing will happen after we've done work and thus we'll only get here if we've completed writing the root in which case we can writeResources at any time and simply want them to be near the top so the browser (or other host) receives them first

@sizebot
Copy link

sizebot commented Jul 14, 2022

Comparing: 3ddbedd...b633ab0

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.16% 132.92 kB 133.13 kB +0.15% 42.68 kB 42.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +1.72% 138.15 kB 140.53 kB +2.12% 44.19 kB 45.13 kB
facebook-www/ReactDOM-prod.classic.js +0.12% 469.02 kB 469.58 kB +0.10% 84.22 kB 84.31 kB
facebook-www/ReactDOM-prod.modern.js +0.12% 454.26 kB 454.82 kB +0.11% 81.98 kB 82.07 kB
facebook-www/ReactDOMForked-prod.classic.js +0.12% 469.02 kB 469.58 kB +0.10% 84.22 kB 84.31 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +6.76% 83.29 kB 88.92 kB +6.22% 17.56 kB 18.65 kB
facebook-www/ReactDOMServer-prod.modern.js +6.59% 80.31 kB 85.60 kB +6.13% 16.75 kB 17.77 kB
facebook-www/ReactDOMServer-prod.classic.js +6.38% 83.24 kB 88.55 kB +6.22% 17.34 kB 18.42 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.30% 38.79 kB 40.85 kB +5.68% 12.77 kB 13.50 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.30% 38.82 kB 40.88 kB +5.67% 12.80 kB 13.52 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.min.js +5.25% 39.05 kB 41.10 kB +5.45% 13.29 kB 14.02 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.min.js +5.25% 39.07 kB 41.12 kB +5.46% 13.31 kB 14.04 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.24% 39.29 kB 41.35 kB +5.63% 12.96 kB 13.69 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.19% 35.01 kB 36.83 kB +5.74% 11.61 kB 12.28 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.min.js +5.19% 39.55 kB 41.60 kB +5.41% 13.47 kB 14.20 kB
oss-experimental/react-dom/cjs/react-dom-static.node.production.min.js +5.18% 39.51 kB 41.56 kB +5.44% 13.47 kB 14.20 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.18% 35.04 kB 36.85 kB +5.72% 11.63 kB 12.30 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.16% 35.12 kB 36.94 kB +6.02% 11.74 kB 12.44 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.16% 35.15 kB 36.96 kB +6.02% 11.75 kB 12.46 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.12% 35.45 kB 37.27 kB +5.82% 11.77 kB 12.46 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.10% 35.57 kB 37.38 kB +6.13% 11.89 kB 12.62 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.min.js +5.07% 35.63 kB 37.43 kB +5.67% 12.26 kB 12.95 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.min.js +5.06% 35.65 kB 37.45 kB +5.68% 12.28 kB 12.97 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.production.min.js +5.02% 35.73 kB 37.52 kB +5.62% 12.39 kB 13.08 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.production.min.js +5.02% 35.95 kB 37.75 kB +5.57% 12.39 kB 13.08 kB
oss-stable/react-dom/umd/react-dom-server.browser.production.min.js +5.02% 35.75 kB 37.55 kB +5.61% 12.41 kB 13.10 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.min.js +5.00% 36.07 kB 37.87 kB +5.56% 12.43 kB 13.13 kB
oss-experimental/react-dom/umd/react-dom-server.browser.production.min.js +4.97% 36.17 kB 37.97 kB +5.47% 12.55 kB 13.24 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.development.js +3.76% 255.03 kB 264.63 kB +3.88% 59.72 kB 62.03 kB
oss-stable/react-dom/umd/react-dom-server.browser.development.js +3.76% 255.05 kB 264.65 kB +3.88% 59.74 kB 62.06 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.development.js +3.75% 256.09 kB 265.69 kB +3.86% 59.59 kB 61.90 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.development.js +3.75% 256.12 kB 265.72 kB +3.86% 59.62 kB 61.92 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js +3.74% 256.69 kB 266.29 kB +3.83% 60.14 kB 62.45 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js +3.72% 257.75 kB 267.35 kB +3.82% 60.02 kB 62.32 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +3.72% 245.99 kB 255.15 kB +4.03% 58.47 kB 60.83 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js +3.72% 243.15 kB 252.20 kB +3.93% 59.02 kB 61.34 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js +3.72% 243.18 kB 252.22 kB +3.92% 59.05 kB 61.36 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.development.js +3.71% 244.03 kB 253.07 kB +3.85% 59.26 kB 61.55 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.70% 244.19 kB 253.24 kB +3.95% 58.89 kB 61.21 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.70% 244.22 kB 253.26 kB +3.94% 58.90 kB 61.23 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js +3.70% 244.35 kB 253.40 kB +3.92% 58.94 kB 61.25 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js +3.70% 244.38 kB 253.42 kB +3.91% 58.97 kB 61.27 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +3.69% 244.72 kB 253.76 kB +3.86% 59.46 kB 61.75 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.68% 245.76 kB 254.80 kB +3.85% 59.34 kB 61.62 kB
oss-experimental/react-dom/cjs/react-dom-static.node.development.js +3.68% 245.88 kB 254.92 kB +3.81% 59.48 kB 61.75 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js +3.68% 245.90 kB 254.94 kB +3.85% 59.39 kB 61.68 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +3.68% 245.92 kB 254.96 kB +3.83% 59.38 kB 61.66 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js +3.68% 245.93 kB 254.97 kB +3.85% 59.41 kB 61.70 kB
facebook-www/ReactDOMServer-dev.modern.js +3.66% 250.42 kB 259.57 kB +3.86% 59.52 kB 61.82 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +3.65% 247.47 kB 256.51 kB +3.83% 59.81 kB 62.10 kB
facebook-www/ReactDOMServer-dev.classic.js +3.56% 257.07 kB 266.23 kB +3.76% 60.94 kB 63.23 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable-semver/react-server/cjs/react-server.production.min.js +2.03% 20.92 kB 21.35 kB +2.37% 7.18 kB 7.35 kB
oss-stable/react-server/cjs/react-server.production.min.js +2.03% 20.92 kB 21.35 kB +2.37% 7.18 kB 7.35 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactDOMServerStreaming-prod.modern.js +6.76% 83.29 kB 88.92 kB +6.22% 17.56 kB 18.65 kB
facebook-www/ReactDOMServer-prod.modern.js +6.59% 80.31 kB 85.60 kB +6.13% 16.75 kB 17.77 kB
facebook-www/ReactDOMServer-prod.classic.js +6.38% 83.24 kB 88.55 kB +6.22% 17.34 kB 18.42 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.30% 38.79 kB 40.85 kB +5.68% 12.77 kB 13.50 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.30% 38.82 kB 40.88 kB +5.67% 12.80 kB 13.52 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.min.js +5.25% 39.05 kB 41.10 kB +5.45% 13.29 kB 14.02 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.min.js +5.25% 39.07 kB 41.12 kB +5.46% 13.31 kB 14.04 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.min.js +5.24% 39.29 kB 41.35 kB +5.63% 12.96 kB 13.69 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.19% 35.01 kB 36.83 kB +5.74% 11.61 kB 12.28 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.min.js +5.19% 39.55 kB 41.60 kB +5.41% 13.47 kB 14.20 kB
oss-experimental/react-dom/cjs/react-dom-static.node.production.min.js +5.18% 39.51 kB 41.56 kB +5.44% 13.47 kB 14.20 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.18% 35.04 kB 36.85 kB +5.72% 11.63 kB 12.30 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.16% 35.12 kB 36.94 kB +6.02% 11.74 kB 12.44 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.16% 35.15 kB 36.96 kB +6.02% 11.75 kB 12.46 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.min.js +5.12% 35.45 kB 37.27 kB +5.82% 11.77 kB 12.46 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.production.min.js +5.10% 35.57 kB 37.38 kB +6.13% 11.89 kB 12.62 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.min.js +5.07% 35.63 kB 37.43 kB +5.67% 12.26 kB 12.95 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.min.js +5.06% 35.65 kB 37.45 kB +5.68% 12.28 kB 12.97 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.production.min.js +5.02% 35.73 kB 37.52 kB +5.62% 12.39 kB 13.08 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.production.min.js +5.02% 35.95 kB 37.75 kB +5.57% 12.39 kB 13.08 kB
oss-stable/react-dom/umd/react-dom-server.browser.production.min.js +5.02% 35.75 kB 37.55 kB +5.61% 12.41 kB 13.10 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.min.js +5.00% 36.07 kB 37.87 kB +5.56% 12.43 kB 13.13 kB
oss-experimental/react-dom/umd/react-dom-server.browser.production.min.js +4.97% 36.17 kB 37.97 kB +5.47% 12.55 kB 13.24 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.production.min.js +4.46% 2.96 kB 3.09 kB +3.00% 1.14 kB 1.17 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.development.js +3.76% 255.03 kB 264.63 kB +3.88% 59.72 kB 62.03 kB
oss-stable/react-dom/umd/react-dom-server.browser.development.js +3.76% 255.05 kB 264.65 kB +3.88% 59.74 kB 62.06 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.development.js +3.75% 256.09 kB 265.69 kB +3.86% 59.59 kB 61.90 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.development.js +3.75% 256.12 kB 265.72 kB +3.86% 59.62 kB 61.92 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js +3.74% 256.69 kB 266.29 kB +3.83% 60.14 kB 62.45 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js +3.72% 257.75 kB 267.35 kB +3.82% 60.02 kB 62.32 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +3.72% 245.99 kB 255.15 kB +4.03% 58.47 kB 60.83 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js +3.72% 243.15 kB 252.20 kB +3.93% 59.02 kB 61.34 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js +3.72% 243.18 kB 252.22 kB +3.92% 59.05 kB 61.36 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.development.js +3.71% 244.03 kB 253.07 kB +3.85% 59.26 kB 61.55 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.70% 244.19 kB 253.24 kB +3.95% 58.89 kB 61.21 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.70% 244.22 kB 253.26 kB +3.94% 58.90 kB 61.23 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js +3.70% 244.35 kB 253.40 kB +3.92% 58.94 kB 61.25 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js +3.70% 244.38 kB 253.42 kB +3.91% 58.97 kB 61.27 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +3.69% 244.72 kB 253.76 kB +3.86% 59.46 kB 61.75 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +3.68% 245.76 kB 254.80 kB +3.85% 59.34 kB 61.62 kB
oss-experimental/react-dom/cjs/react-dom-static.node.development.js +3.68% 245.88 kB 254.92 kB +3.81% 59.48 kB 61.75 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js +3.68% 245.90 kB 254.94 kB +3.85% 59.39 kB 61.68 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +3.68% 245.92 kB 254.96 kB +3.83% 59.38 kB 61.66 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js +3.68% 245.93 kB 254.97 kB +3.85% 59.41 kB 61.70 kB
facebook-www/ReactDOMServer-dev.modern.js +3.66% 250.42 kB 259.57 kB +3.86% 59.52 kB 61.82 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +3.65% 247.47 kB 256.51 kB +3.83% 59.81 kB 62.10 kB
facebook-www/ReactDOMServer-dev.classic.js +3.56% 257.07 kB 266.23 kB +3.76% 60.94 kB 63.23 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-server.development.js +2.94% 6.16 kB 6.34 kB +2.81% 1.71 kB 1.75 kB
oss-stable-semver/react-server/cjs/react-server.production.min.js +2.03% 20.92 kB 21.35 kB +2.37% 7.18 kB 7.35 kB
oss-stable/react-server/cjs/react-server.production.min.js +2.03% 20.92 kB 21.35 kB +2.37% 7.18 kB 7.35 kB
oss-experimental/react-server/cjs/react-server.production.min.js +1.99% 21.25 kB 21.68 kB +2.39% 7.28 kB 7.45 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +1.72% 138.15 kB 140.53 kB +2.12% 44.19 kB 45.13 kB
oss-experimental/react-dom/umd/react-dom.production.min.js +1.72% 138.20 kB 140.58 kB +1.94% 44.86 kB 45.72 kB
oss-experimental/react-dom/umd/react-dom.profiling.min.js +1.60% 147.06 kB 149.41 kB +2.02% 47.10 kB 48.05 kB
oss-experimental/react-dom/cjs/react-dom.profiling.min.js +1.59% 147.68 kB 150.04 kB +1.94% 46.62 kB 47.53 kB
oss-experimental/react-dom/umd/react-dom.development.js +1.34% 1,123.28 kB 1,138.33 kB +1.48% 242.49 kB 246.09 kB
oss-experimental/react-dom/cjs/react-dom.development.js +1.34% 1,070.81 kB 1,085.11 kB +1.49% 239.82 kB 243.38 kB
oss-stable-semver/react-server/cjs/react-server.development.js +0.99% 130.50 kB 131.79 kB +0.88% 32.67 kB 32.96 kB
oss-stable/react-server/cjs/react-server.development.js +0.99% 130.50 kB 131.79 kB +0.88% 32.67 kB 32.96 kB
oss-experimental/react-server/cjs/react-server.development.js +0.98% 131.37 kB 132.66 kB +0.88% 32.88 kB 33.17 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.min.js +0.97% 98.96 kB 99.91 kB +1.05% 30.37 kB 30.69 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.min.js +0.86% 107.86 kB 108.79 kB +0.59% 32.65 kB 32.84 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.66% 12.37 kB 12.45 kB +0.81% 3.68 kB 3.71 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.66% 12.37 kB 12.45 kB +0.81% 3.68 kB 3.71 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.min.js +0.66% 12.37 kB 12.45 kB +0.81% 3.68 kB 3.71 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.66% 12.44 kB 12.52 kB +0.84% 3.70 kB 3.73 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.66% 12.44 kB 12.52 kB +0.84% 3.70 kB 3.73 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js +0.66% 12.44 kB 12.52 kB +0.84% 3.70 kB 3.73 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js +0.63% 760.48 kB 765.28 kB +0.66% 162.17 kB 163.24 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js +0.63% 760.51 kB 765.31 kB +0.65% 162.20 kB 163.26 kB
oss-experimental/react-reconciler/cjs/react-reconciler.development.js +0.61% 788.44 kB 793.24 kB +0.61% 168.11 kB 169.14 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.53% 41.09 kB 41.31 kB +0.47% 10.47 kB 10.52 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.53% 41.09 kB 41.31 kB +0.47% 10.47 kB 10.52 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.53% 41.09 kB 41.31 kB +0.47% 10.47 kB 10.52 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.development.js +0.31% 34.48 kB 34.58 kB +0.34% 7.76 kB 7.78 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js +0.31% 34.48 kB 34.58 kB +0.34% 7.76 kB 7.78 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js +0.31% 34.48 kB 34.58 kB +0.34% 7.76 kB 7.78 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.31% 34.61 kB 34.72 kB +0.32% 7.78 kB 7.80 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.31% 34.61 kB 34.72 kB +0.32% 7.78 kB 7.80 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.31% 34.61 kB 34.72 kB +0.32% 7.78 kB 7.80 kB
oss-stable-semver/react-art/cjs/react-art.development.js +0.21% 693.79 kB 695.21 kB +0.17% 150.17 kB 150.43 kB
oss-stable/react-art/cjs/react-art.development.js +0.21% 693.81 kB 695.24 kB +0.17% 150.19 kB 150.46 kB
oss-stable-semver/react-test-renderer/umd/react-test-renderer.development.js +0.20% 698.38 kB 699.79 kB +0.19% 146.85 kB 147.13 kB
oss-stable/react-test-renderer/umd/react-test-renderer.development.js +0.20% 698.41 kB 699.82 kB +0.19% 146.87 kB 147.16 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js +0.20% 666.62 kB 667.96 kB +0.21% 145.28 kB 145.59 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js +0.20% 666.65 kB 667.99 kB +0.21% 145.31 kB 145.61 kB

Generated by 🚫 dangerJS against b633ab0

This change implements Float for a minimal use case of hoisting stylesheet resources to the head and ensuring the flush in the appropriate spot in the stream. Subsequent commits will add support for client stylesheet hoisting and Flight resources.

While there is some additional buildout of Float capabilities in general the public APIs have all been removed. The intent with this first implementation is to opt in <link rel="stylesheet"> use the more useful semantics of resources
Resources are implemented as a new fiber type HostResource which expect ref counting and hoisting semantics. Currently only react-dom supports this and it is only enabled if the `enableFloat` flag is true.

When encountering a resource we don't append it to the parent host component like usual. In the commit phase the resource is "acquired" and if necessary a domElement is created and inserted into the Document head. If a HostResource fiber is deleted the resource is "released" and if that was the last referrer to that resource is is removed from the document.

Hydration poses a special challenge. We want to skip over resources in hydration because they may not have a matching element during render. This will become more prevalent when Float apis like `preinit(...)` are available. However if the resource exists because of a component rendering we should ideally opt into ref counting semnatics. The current approach is to consume hydratable resources in commit (if any are acquired we opt into ref counting mode) and if there are any remaining we assume they are static resources and hoist them permanently.
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.

3 participants