@@ -211,7 +211,9 @@ module.exports = env => {
211
211
loader : "ts-loader" ,
212
212
options : {
213
213
configFile : tsConfigPath ,
214
- transpileOnly : ! ! hmr ,
214
+ // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
215
+ // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
216
+ transpileOnly : true ,
215
217
allowTsInNodeModules : true ,
216
218
compilerOptions : {
217
219
sourceMap : isAnySourceMapEnabled ,
@@ -256,6 +258,14 @@ module.exports = env => {
256
258
} ) ,
257
259
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
258
260
new nsWebpack . WatchStateLoggerPlugin ( ) ,
261
+ // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
262
+ // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
263
+ new ForkTsCheckerWebpackPlugin ( {
264
+ tsconfig : tsConfigPath ,
265
+ async : false ,
266
+ useTypescriptIncrementalApi : true ,
267
+ memoryLimit : 4096
268
+ } )
259
269
] ,
260
270
} ;
261
271
@@ -295,12 +305,6 @@ module.exports = env => {
295
305
296
306
if ( hmr ) {
297
307
config . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) ) ;
298
-
299
- // With HMR ts-loader should run in `transpileOnly` mode,
300
- // so assure type-checking with fork-ts-checker-webpack-plugin
301
- config . plugins . push ( new ForkTsCheckerWebpackPlugin ( {
302
- tsconfig : tsConfigPath
303
- } ) ) ;
304
308
}
305
309
306
310
0 commit comments