facebook / flipper

A desktop debugging platform for mobile developers.
https://fbflipper.com/
MIT License
13.36k stars 955 forks source link

After migrating to esbuild HMR no longer works on local dev plugins #4152

Open aeroxy opened 2 years ago

aeroxy commented 2 years ago

Previously we use getWatchFolders for Metro to ensure local dev plugin projects are watched when running with the fast-refresh flag. After migrating to esbuild we lose this feature, and while developing local dev plugins, we would need to refresh the flipper manually and lose all the states.

aeroxy commented 2 years ago

@aigoncharov should look into this.

aigoncharov commented 2 years ago

@aeroxy the plugins are still watched (https://github.com/facebook/flipper/blob/277d730f77192092219d55102117628e660b6be7/desktop/scripts/start-dev-server.tsx#L416) and they should be reloaded automatically (https://github.com/facebook/flipper/blob/main/desktop/flipper-ui-core/src/dispatcher/pluginsSourceUpdateListener.tsx). But as you say the plugins currently lose their state. We might build custom integration with react-refresh/runtime in future, but it is not on the roadmap though. We'd be happy to accept a PR for it though.

aeroxy commented 2 years ago

@aeroxy the plugins are still watched (

https://github.com/facebook/flipper/blob/277d730f77192092219d55102117628e660b6be7/desktop/scripts/start-dev-server.tsx#L416

) and they should be reloaded automatically (https://github.com/facebook/flipper/blob/main/desktop/flipper-ui-core/src/dispatcher/pluginsSourceUpdateListener.tsx). But as you say the plugins currently lose their state. We might build custom integration with react-refresh/runtime in future, but it is not on the roadmap though. We'd be happy to accept a PR for it though.

Ok, let me give it a shot.

aigoncharov commented 2 years ago

This might be a good place to start https://github.com/facebook/react/issues/16604#issuecomment-528663101