@@ -42,24 +42,37 @@ function log(level, msg) {
42
42
return console . error ( msg ) ;
43
43
}
44
44
45
+ // Send messages to the outside, so plugins can consume it.
46
+ function sendMsg ( type , data ) {
47
+ if ( typeof self !== "undefined" ) {
48
+ self . postMessage ( {
49
+ type : "webpack" + type ,
50
+ data : data
51
+ } , "*" ) ;
52
+ }
53
+ }
54
+
45
55
var onSocketMsg = {
46
56
hot : function ( ) {
47
57
hot = true ;
48
58
log ( "info" , "[WDS] Hot Module Replacement enabled." ) ;
49
59
} ,
50
60
invalid : function ( ) {
51
61
log ( "info" , "[WDS] App updated. Recompiling..." ) ;
62
+ sendMsg ( "Invalid" ) ;
52
63
} ,
53
64
hash : function ( hash ) {
54
65
currentHash = hash ;
55
66
} ,
56
67
"still-ok" : function ( ) {
57
68
log ( "info" , "[WDS] Nothing changed." )
69
+ sendMsg ( "StillOk" ) ;
58
70
} ,
59
71
"log-level" : function ( level ) {
60
72
logLevel = level ;
61
73
} ,
62
74
ok : function ( ) {
75
+ sendMsg ( "Ok" ) ;
63
76
if ( initial ) return initial = false ;
64
77
reloadApp ( ) ;
65
78
} ,
@@ -69,16 +82,19 @@ var onSocketMsg = {
69
82
} ,
70
83
warnings : function ( warnings ) {
71
84
log ( "info" , "[WDS] Warnings while compiling. Reload prevented." ) ;
85
+ sendMsg ( "Warnings" , warnings ) ;
72
86
for ( var i = 0 ; i < warnings . length ; i ++ )
73
87
console . warn ( stripAnsi ( warnings [ i ] ) ) ;
74
88
} ,
75
89
errors : function ( errors ) {
76
90
log ( "info" , "[WDS] Errors while compiling. Reload prevented." ) ;
91
+ sendMsg ( "Errors" , errors ) ;
77
92
for ( var i = 0 ; i < errors . length ; i ++ )
78
93
console . error ( stripAnsi ( errors [ i ] ) ) ;
79
94
} ,
80
95
close : function ( ) {
81
96
log ( "error" , "[WDS] Disconnected!" ) ;
97
+ sendMsg ( "Close" ) ;
82
98
}
83
99
} ;
84
100
0 commit comments