@@ -135,27 +135,16 @@ function createCompiler(
135
135
} ) ;
136
136
137
137
let isFirstCompile = true ;
138
- let isTsCheckInProgress = false ;
139
138
let tsMessagesPromise ;
140
139
let tsMessagesResolver ;
141
140
142
141
if ( useTypeScript ) {
143
142
compiler . hooks . beforeCompile . tap ( 'beforeCompile' , ( ) => {
144
- isTsCheckInProgress = true ;
145
143
tsMessagesPromise = new Promise ( resolve => {
146
- tsMessagesResolver = msgs => {
147
- isTsCheckInProgress = false ;
148
- resolve ( msgs ) ;
149
- } ;
144
+ tsMessagesResolver = msgs => resolve ( msgs ) ;
150
145
} ) ;
151
146
} ) ;
152
147
153
- compiler . hooks . compilation . tap ( 'compilation' , async compilation => {
154
- const messages = await tsMessagesPromise ;
155
- compilation . errors . push ( ...messages . errors ) ;
156
- compilation . warnings . push ( ...messages . warnings ) ;
157
- } ) ;
158
-
159
148
forkTsCheckerWebpackPlugin
160
149
. getCompilerHooks ( compiler )
161
150
. receive . tap ( 'afterTypeScriptCheck' , ( diagnostics , lints ) => {
@@ -190,17 +179,25 @@ function createCompiler(
190
179
errors : true ,
191
180
} ) ;
192
181
193
- if ( useTypeScript && statsData . errors . length === 0 && isTsCheckInProgress ) {
194
- console . log (
195
- chalk . yellow (
196
- 'Files successfully emitted, waiting for typecheck results...'
197
- )
198
- ) ;
182
+ if ( useTypeScript && statsData . errors . length === 0 ) {
183
+ const delayedMsg = setTimeout ( ( ) => {
184
+ console . log (
185
+ chalk . yellow (
186
+ 'Files successfully emitted, waiting for typecheck results...'
187
+ )
188
+ ) ;
189
+ } , 100 ) ;
199
190
200
191
const messages = await tsMessagesPromise ;
192
+ clearTimeout ( delayedMsg ) ;
201
193
statsData . errors . push ( ...messages . errors ) ;
202
194
statsData . warnings . push ( ...messages . warnings ) ;
203
195
196
+ // Push errors and warnings into compilation result
197
+ // to show them after page refresh triggered by user.
198
+ stats . compilation . errors . push ( ...messages . errors ) ;
199
+ stats . compilation . warnings . push ( ...messages . warnings ) ;
200
+
204
201
if ( messages . errors . length > 0 ) {
205
202
devSocket . errors ( messages . errors ) ;
206
203
} else if ( messages . warnings . length > 0 ) {
0 commit comments