1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const errorEventHandlers = require('./utils/errorEventHandlers');
- const formatWebpackErrors = require('./utils/formatWebpackErrors');
- let isHotReload = false;
- let hasRuntimeErrors = false;
- function tryDismissErrorOverlay() {
- __react_refresh_error_overlay__.clearCompileError();
- __react_refresh_error_overlay__.clearRuntimeErrors(!hasRuntimeErrors);
- hasRuntimeErrors = false;
- }
- function handleCompileSuccess() {
- isHotReload = true;
- if (isHotReload) {
- tryDismissErrorOverlay();
- }
- }
- function handleCompileErrors(errors) {
- isHotReload = true;
- const formattedErrors = formatWebpackErrors(errors);
-
- __react_refresh_error_overlay__.showCompileError(formattedErrors[0]);
- }
- function compileMessageHandler(message) {
- switch (message.type) {
- case 'ok':
- case 'still-ok':
- case 'warnings': {
-
- handleCompileSuccess();
- break;
- }
- case 'errors': {
- handleCompileErrors(message.data);
- break;
- }
- default: {
-
- }
- }
- }
- if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
-
- __react_refresh_init_socket__(compileMessageHandler, __resourceQuery);
-
- errorEventHandlers.error(function handleError(error) {
- hasRuntimeErrors = true;
- __react_refresh_error_overlay__.handleRuntimeError(error);
- });
- errorEventHandlers.unhandledRejection(function handleUnhandledPromiseRejection(error) {
- hasRuntimeErrors = true;
- __react_refresh_error_overlay__.handleRuntimeError(error);
- });
- }
|