@@ -65,24 +65,24 @@ function sendMsg(type, data) {
6565 ! ( self instanceof WorkerGlobalScope ) )
6666 ) {
6767 self . postMessage ( {
68- type : ' webpack' + type ,
69- data : data
68+ type : ` webpack${ type } ` ,
69+ data
7070 } , '*' ) ;
7171 }
7272}
7373
7474const onSocketMsg = {
75- hot : function msgHot ( ) {
75+ hot ( ) {
7676 hot = true ;
7777 log . info ( '[WDS] Hot Module Replacement enabled.' ) ;
7878 } ,
79- invalid : function msgInvalid ( ) {
79+ invalid ( ) {
8080 log . info ( '[WDS] App updated. Recompiling...' ) ;
8181 // fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
8282 if ( useWarningOverlay || useErrorOverlay ) overlay . clear ( ) ;
8383 sendMsg ( 'Invalid' ) ;
8484 } ,
85- hash : function msgHash ( hash ) {
85+ hash ( hash ) {
8686 currentHash = hash ;
8787 } ,
8888 'still-ok' : function stillOk ( ) {
@@ -108,10 +108,10 @@ const onSocketMsg = {
108108 log . disableAll ( ) ;
109109 break ;
110110 default :
111- log . error ( ' [WDS] Unknown clientLogLevel \'' + level + '\'' ) ;
111+ log . error ( ` [WDS] Unknown clientLogLevel ' ${ level } '` ) ;
112112 }
113113 } ,
114- overlay : function msgOverlay ( value ) {
114+ overlay ( value ) {
115115 if ( typeof document !== 'undefined' ) {
116116 if ( typeof ( value ) === 'boolean' ) {
117117 useWarningOverlay = false ;
@@ -122,15 +122,15 @@ const onSocketMsg = {
122122 }
123123 }
124124 } ,
125- progress : function msgProgress ( progress ) {
125+ progress ( progress ) {
126126 if ( typeof document !== 'undefined' ) {
127127 useProgress = progress ;
128128 }
129129 } ,
130130 'progress-update' : function progressUpdate ( data ) {
131- if ( useProgress ) log . info ( ' [WDS] ' + data . percent + ' % - ' + data . msg + '.' ) ;
131+ if ( useProgress ) log . info ( ` [WDS] ${ data . percent } % - ${ data . msg } .` ) ;
132132 } ,
133- ok : function msgOk ( ) {
133+ ok ( ) {
134134 sendMsg ( 'Ok' ) ;
135135 if ( useWarningOverlay || useErrorOverlay ) overlay . clear ( ) ;
136136 if ( initial ) return initial = false ; // eslint-disable-line no-return-assign
@@ -140,27 +140,27 @@ const onSocketMsg = {
140140 log . info ( '[WDS] Content base changed. Reloading...' ) ;
141141 self . location . reload ( ) ;
142142 } ,
143- warnings : function msgWarnings ( warnings ) {
143+ warnings ( warnings ) {
144144 log . warn ( '[WDS] Warnings while compiling.' ) ;
145- const strippedWarnings = warnings . map ( function map ( warning ) { return stripAnsi ( warning ) ; } ) ;
145+ const strippedWarnings = warnings . map ( warning => stripAnsi ( warning ) ) ;
146146 sendMsg ( 'Warnings' , strippedWarnings ) ;
147147 for ( let i = 0 ; i < strippedWarnings . length ; i ++ ) { log . warn ( strippedWarnings [ i ] ) ; }
148148 if ( useWarningOverlay ) overlay . showMessage ( warnings ) ;
149149
150150 if ( initial ) return initial = false ; // eslint-disable-line no-return-assign
151151 reloadApp ( ) ;
152152 } ,
153- errors : function msgErrors ( errors ) {
153+ errors ( errors ) {
154154 log . error ( '[WDS] Errors while compiling. Reload prevented.' ) ;
155- const strippedErrors = errors . map ( function map ( error ) { return stripAnsi ( error ) ; } ) ;
155+ const strippedErrors = errors . map ( error => stripAnsi ( error ) ) ;
156156 sendMsg ( 'Errors' , strippedErrors ) ;
157157 for ( let i = 0 ; i < strippedErrors . length ; i ++ ) { log . error ( strippedErrors [ i ] ) ; }
158158 if ( useErrorOverlay ) overlay . showMessage ( errors ) ;
159159 } ,
160- error : function msgError ( error ) {
160+ error ( error ) {
161161 log . error ( error ) ;
162162 } ,
163- close : function msgClose ( ) {
163+ close ( ) {
164164 log . error ( '[WDS] Disconnected!' ) ;
165165 sendMsg ( 'Close' ) ;
166166 }
@@ -190,17 +190,17 @@ if (hostname && (self.location.protocol === 'https:' || urlParts.hostname === '0
190190}
191191
192192const socketUrl = url . format ( {
193- protocol : protocol ,
193+ protocol,
194194 auth : urlParts . auth ,
195- hostname : hostname ,
195+ hostname,
196196 port : urlParts . port ,
197197 pathname : urlParts . path == null || urlParts . path === '/' ? '/sockjs-node' : urlParts . path
198198} ) ;
199199
200200socket ( socketUrl , onSocketMsg ) ;
201201
202202let isUnloading = false ;
203- self . addEventListener ( 'beforeunload' , function beforeUnload ( ) {
203+ self . addEventListener ( 'beforeunload' , ( ) => {
204204 isUnloading = true ;
205205} ) ;
206206
@@ -215,12 +215,12 @@ function reloadApp() {
215215 hotEmitter . emit ( 'webpackHotUpdate' , currentHash ) ;
216216 if ( typeof self !== 'undefined' && self . window ) {
217217 // broadcast update to window
218- self . postMessage ( ' webpackHotUpdate' + currentHash , '*' ) ;
218+ self . postMessage ( ` webpackHotUpdate${ currentHash } ` , '*' ) ;
219219 }
220220 } else {
221221 let rootWindow = self ;
222222 // use parent window for reload (in case we're in an iframe with no valid src)
223- const intervalId = self . setInterval ( function findRootWindow ( ) {
223+ const intervalId = self . setInterval ( ( ) => {
224224 if ( rootWindow . location . protocol !== 'about:' ) {
225225 // reload immediately if protocol is valid
226226 applyReload ( rootWindow , intervalId ) ;
0 commit comments