File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
33const { createRefreshTemplate, injectRefreshEntry, validateOptions } = require ( './helpers' ) ;
4- const { refreshUtils } = require ( './runtime/globals' ) ;
4+ const { errorOverlay , refreshUtils } = require ( './runtime/globals' ) ;
55
66class ReactRefreshPlugin {
77 /**
@@ -36,6 +36,7 @@ class ReactRefreshPlugin {
3636
3737 // Inject refresh utilities to Webpack's global scope
3838 const providePlugin = new webpack . ProvidePlugin ( {
39+ [ errorOverlay ] : this . options . overlay && require . resolve ( this . options . overlay . module ) ,
3940 [ refreshUtils ] : require . resolve ( './runtime/utils' ) ,
4041 } ) ;
4142 providePlugin . apply ( compiler ) ;
Original file line number Diff line number Diff line change 1+ module . exports . errorOverlay = '__react_refresh_error_overlay__' ;
2+
13module . exports . refreshUtils = '__react_refresh_utils__' ;
Original file line number Diff line number Diff line change 1+ /* global __react_refresh_error_overlay__ */
12const Refresh = require ( 'react-refresh/runtime' ) ;
2- const ErrorOverlay = require ( '../overlay' ) ;
33
44/**
55 * Extracts exports from a webpack module object.
@@ -73,7 +73,9 @@ function createHotErrorHandler(moduleId) {
7373 * @returns {void }
7474 */
7575 function hotErrorHandler ( error ) {
76- ErrorOverlay . handleRuntimeError ( error ) ;
76+ if ( __react_refresh_error_overlay__ ) {
77+ __react_refresh_error_overlay__ . handleRuntimeError ( error ) ;
78+ }
7779 }
7880
7981 /**
@@ -109,7 +111,9 @@ function createDebounceUpdate() {
109111 refreshTimeout = setTimeout ( function ( ) {
110112 refreshTimeout = undefined ;
111113 Refresh . performReactRefresh ( ) ;
112- ErrorOverlay . clearRuntimeErrors ( ) ;
114+ if ( __react_refresh_error_overlay__ ) {
115+ __react_refresh_error_overlay__ . clearRuntimeErrors ( ) ;
116+ }
113117 } , 30 ) ;
114118 }
115119 }
You can’t perform that action at this time.
0 commit comments