Closed cpojer closed 6 years ago
That's awesome! I love it! 💯
Completely agree with the next steps, one question though:
Load the metro-web client as a separate bundle from Metro, this should never fail compilation
Is this to reuse the same WebSocket connection between the different bundles? I think I'd prefer to not require users to include one additional script tag, and just embed the client inside the bundle (in the case of multiple bundles per page, the HmrClient could detect if there's already another client and fallback to it (or even better, bundle splitting 😄 )
Oh I didn't see this! If we make the user require it, if their app has an issue with the compilation, we won't be able to hook in the error handler. However, we could spit out the bundle for metro-web in case the main bundle errors out.
This is a basic version of an error overlay for Metro's HMR server. It's based on create-react-app's
react-error-overlay
. I know that weeks of work went into making that overlay solid. It's implementation is sound (an iframe with the highest z-index served by a single file bundle that includes React) and battle tested inside of create-react-app.The behavior is incomplete but should kick this effort off the ground:
In the sample app, this is incredibly fast:
Next steps:
MetroClient.listen('path/to/bundle')
. This is convenient because we can make sure to listen to many bundles at the same time as well as we don't need to make the URL/entry points configurable from within user code.@rafeca what do you think about these next steps?