Historical list of DATA is retained like the following via prevExports:
This PR breaks the chain by only passing absolutely necessary data across fast-refreshes, which is signature: string[] and isReactRefreshBoundary: boolean. So it will be impossible to accidentally form this kind of reference chain.
When fast-refreshing the following code:
each refresh will not purge the previous DATA since we chain
prevExports
, which referencesApp
, which closes overDATA
. For reproducible example and more detailed explanation, please check https://github.com/naruaway-sandbox/fast-refresh-hmr-memory-leak-demoHistorical list of DATA is retained like the following via prevExports:
This PR breaks the chain by only passing absolutely necessary data across fast-refreshes, which is
signature: string[]
andisReactRefreshBoundary: boolean
. So it will be impossible to accidentally form this kind of reference chain.Note that I also tried to fix the same issue in Next.js https://github.com/vercel/next.js/pull/53797
Verification
I verified using this PR with https://github.com/naruaway-sandbox/fast-refresh-hmr-memory-leak-demo and confirmed that Fast Refresh itself is working well while not causing the memory leak