oblador / react-native-esbuild

Fast bundler and dev server for react-native using esbuild
MIT License
595 stars 11 forks source link

Enable log forwarding and live reload over HMR socket #13

Closed oblador closed 2 years ago

oblador commented 2 years ago

With metro, React Native will proxy console.logs to the HMR server that then gets logged to the terminal, a functionality currently lacking in this library.

This PR implements a basic HMR endpoint simply for log forwarding purposes. When that is established we can also hack the HMR update API to inject arbitrary code to force a reload of the application. Currently that is done via the message socket that is primarily intended for user interaction with the terminal process and therefore would often throw warnings when no clients are connected (for example because they are loading the bundle). This approach also sucks because there is no way to opt out of it. With the HMR hack we get ability to opt out via the dev menu just like with metro.