Data Prefetch
Deprecated
Legacy Data Prefetch has been removed. The .prefetch.ts, dataPrefetch, and @module-federation/enhanced/prefetch APIs are no longer available.
Use bridge-react - prefetch instead. It supports Rspack/Webpack and works in both SSR and CSR scenarios.
How to migrate to bridge-react - prefetch
Producer
- Rename the
.prefetch.tsfile to.data.ts. - Change the default export to a named export called
fetchData. - Remove
dataPrefetchfrom your config file. - If you are using the
deferAPI, remove it. - If the component uses
usePrefetchto fetch data, accept the data viapropsinstead.
The producer does not execute fetchData by itself. It is only called when the consumer loads the module, and the result is injected into the component.
If the producer application also needs to render this component with data, call fetchData before rendering and pass the data via props.
Consumer
- Remove
dataPrefetchfrom your config file. - Use
createLazyComponentto load the producer. See bridge-react - data fetch. - Use prefetch to prefetch data.