dillon1000/react
Commit
Browse files [Flight Parcel] Implement prepareDestinationForModule (#31799)
Followup to #31725 This implements `prepareDestinationForModule` in the Parcel Flight client. On the Parcel side, the `<Resources>` component now only inserts `<link>` elements for stylesheets (along with a bootstrap script when needed), and React is responsible for inserting scripts. This ensures that components that are conditionally dynamic imported during render are also preloaded. CSS must be added to the RSC tree using `<Resources>` to avoid FOUC. This must be manually rendered in both the top-level page, and in any component that is dynamic imported. It would be nice if there was a way for React to automatically insert CSS as well, but unfortunately `prepareDestinationForModule` only knows about client components and not CSS for server components. Perhaps there could be a way we could annotate components at code splitting boundaries with the resources they need? More thoughts in this thread: https://github.com/facebook/react/pull/31725#discussion_r1884867607
Changed paths11 files
First-parent comparisonfixtures/flight-parcel/package.json ModifiedM fixtures/flight-parcel/src/server.tsx ModifiedM fixtures/flight-parcel/types.d.ts ModifiedM fixtures/flight-parcel/yarn.lock ModifiedM packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-parcel.js ModifiedM packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-parcel.js ModifiedM packages/react-client/src/forks/ReactFlightClientConfig.dom-node-parcel.js ModifiedM packages/react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel.js ModifiedA packages/react-server-dom-parcel/src/client/ReactFlightClientConfigTargetParcelBrowser.js AddedA packages/react-server-dom-parcel/src/client/ReactFlightClientConfigTargetParcelServer.js AddedM scripts/flow/environment.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…