loadable-components icon indicating copy to clipboard operation
loadable-components copied to clipboard

Fix lazy components suspending unnecessarily when already preloaded by loadableReady

Open sidhu663 opened this issue 9 months ago • 1 comments

Summary

Currently, when using lazy in combination with SSR (ChunkExtractor on the server side and loadableReady on the client), hydration does not reliably succeed despite the chunks being ready.

This is caused by the suspense branch suspending despite having the module ready and not being in a loading state. By using the existing result when state is not loading, we can avoid suspending and hydrate reliably without mismatches.

The existing logic does not work because there is no cachedPromise if preloaded via loadableReady

Test plan

Added two tests that replicate the babel transformed output when using the plugin.

There are lint failures on files unrelated to this PR that exist on main

sidhu663 avatar Jul 29 '25 20:07 sidhu663

@theKashey @gregberge Any interest in this PR?

sidhu663 avatar Aug 06 '25 20:08 sidhu663