rafeca / metro-sample-app

Super simple web app built by metro
29 stars 8 forks source link

Basic version of an error overlay. #4

Closed cpojer closed 6 years ago

cpojer commented 6 years ago

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: errors

Next steps:

@rafeca what do you think about these next steps?

rafeca commented 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 😄 )

cpojer commented 6 years ago

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.