@@ -211,7 +211,9 @@ module.exports = env => {
211211 loader : "ts-loader" ,
212212 options : {
213213 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 ,
215217 allowTsInNodeModules : true ,
216218 compilerOptions : {
217219 sourceMap : isAnySourceMapEnabled ,
@@ -256,6 +258,14 @@ module.exports = env => {
256258 } ) ,
257259 // Does IPC communication with the {N} CLI to notify events when running in watch mode.
258260 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+ } )
259269 ] ,
260270 } ;
261271
@@ -295,12 +305,6 @@ module.exports = env => {
295305
296306 if ( hmr ) {
297307 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- } ) ) ;
304308 }
305309
306310
0 commit comments