@@ -100,7 +100,7 @@ function printInstructions(appName, urls, useYarn) {
100100 console . log ( ) ;
101101}
102102
103- function createCompiler ( webpack , config , appName , urls , useYarn , useTypeScript , reload ) {
103+ function createCompiler ( webpack , config , appName , urls , useYarn , useTypeScript , devSocket ) {
104104 // "Compiler" is a low-level interface to Webpack.
105105 // It lets us listen to some events and provide our own custom messages.
106106 let compiler ;
@@ -136,28 +136,15 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
136136 } ) ;
137137 } ) ;
138138
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 ) } ` ;
141142
142143 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 ) ,
145146 } ) ;
146147 } ) ;
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- } ) ;
161148 }
162149
163150 // "done" event fires when Webpack has finished recompiling the bundle.
@@ -179,9 +166,20 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
179166 chalk . yellow ( 'Files successfully emitted, waiting for typecheck results...' )
180167 ) ;
181168
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+
185183 process . stdout . clearLine ( ) ;
186184 process . stdout . cursorTo ( 0 ) ;
187185 }
0 commit comments