@@ -100,7 +100,7 @@ function printInstructions(appName, urls, useYarn) {
100
100
console . log ( ) ;
101
101
}
102
102
103
- function createCompiler ( webpack , config , appName , urls , useYarn , useTypeScript , reload ) {
103
+ function createCompiler ( webpack , config , appName , urls , useYarn , useTypeScript , devSocket ) {
104
104
// "Compiler" is a low-level interface to Webpack.
105
105
// It lets us listen to some events and provide our own custom messages.
106
106
let compiler ;
@@ -136,28 +136,15 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
136
136
} ) ;
137
137
} ) ;
138
138
139
- compiler . hooks . forkTsCheckerReceive . tap ( 'fork-ts-checker-done' , msgs => {
140
- const format = ( message ) => `${ message . file } \n${ typescriptFormatter ( message , true ) } ` ;
139
+ compiler . hooks . forkTsCheckerReceive . tap ( 'afterTypeScriptCheck' , ( diagnostics , lints ) => {
140
+ const allMsgs = [ ...diagnostics , ...lints ] ;
141
+ const format = message => `${ message . file } \n${ typescriptFormatter ( message , true ) } ` ;
141
142
142
143
tsMessagesResolver ( {
143
- errors : msgs . filter ( msg => msg . severity === 'error' ) . map ( format ) ,
144
- warnings : msgs . filter ( msg => msg . severity === 'warning' ) . map ( format )
144
+ errors : allMsgs . filter ( msg => msg . severity === 'error' ) . map ( format ) ,
145
+ warnings : allMsgs . filter ( msg => msg . severity === 'warning' ) . map ( format ) ,
145
146
} ) ;
146
147
} ) ;
147
-
148
- compiler . hooks . afterCompile . tap ( 'afterCompile' , async compilation => {
149
- // If any errors already exist, skip this.
150
- if ( compilation . errors . length > 0 ) {
151
- return ;
152
- }
153
-
154
- const messages = await tsMessagesPromise ;
155
- compilation . errors . push ( ...messages . errors ) ;
156
- compilation . warnings . push ( ...messages . warnings ) ;
157
- if ( messages . errors . length > 0 || messages . warnings . length > 0 ) {
158
- reload ( ) ;
159
- }
160
- } ) ;
161
148
}
162
149
163
150
// "done" event fires when Webpack has finished recompiling the bundle.
@@ -179,9 +166,20 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
179
166
chalk . yellow ( 'Files successfully emitted, waiting for typecheck results...' )
180
167
) ;
181
168
182
- const tsMessages = await tsMessagesPromise ;
183
- statsData . errors . push ( ...tsMessages . errors ) ;
184
- statsData . warnings . push ( ...tsMessages . warnings ) ;
169
+ const messages = await tsMessagesPromise ;
170
+ statsData . errors . push ( ...messages . errors ) ;
171
+ statsData . warnings . push ( ...messages . warnings ) ;
172
+ // Push errors and warnings into compilation result
173
+ // to show them after page refresh triggered by user.
174
+ stats . compilation . errors . push ( ...messages . errors ) ;
175
+ stats . compilation . warnings . push ( ...messages . warnings ) ;
176
+
177
+ if ( messages . errors . length > 0 ) {
178
+ devSocket . errors ( messages . errors ) ;
179
+ } else if ( messages . warnings . length > 0 ) {
180
+ devSocket . warnings ( messages . warnings ) ;
181
+ }
182
+
185
183
process . stdout . clearLine ( ) ;
186
184
process . stdout . cursorTo ( 0 ) ;
187
185
}
0 commit comments