From e54fb1b3040f8d8db5dbbb3ce50bc60c807f1fa0 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Wed, 5 Jun 2019 10:48:19 +0300 Subject: [PATCH] fix: move the type check to a child process in order to make it faster in bigger apps and unify the hmr and no-hmr experience. --- templates/webpack.typescript.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 6158e01e..714dc56a 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -211,7 +211,9 @@ module.exports = env => { loader: "ts-loader", options: { configFile: tsConfigPath, - transpileOnly: !!hmr, + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement + transpileOnly: true, allowTsInNodeModules: true, compilerOptions: { sourceMap: isAnySourceMapEnabled, @@ -256,6 +258,14 @@ module.exports = env => { }), // Does IPC communication with the {N} CLI to notify events when running in watch mode. new nsWebpack.WatchStateLoggerPlugin(), + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement + new ForkTsCheckerWebpackPlugin({ + tsconfig: tsConfigPath, + async: false, + useTypescriptIncrementalApi: true, + memoryLimit: 4096 + }) ], }; @@ -295,12 +305,6 @@ module.exports = env => { if (hmr) { config.plugins.push(new webpack.HotModuleReplacementPlugin()); - - // With HMR ts-loader should run in `transpileOnly` mode, - // so assure type-checking with fork-ts-checker-webpack-plugin - config.plugins.push(new ForkTsCheckerWebpackPlugin({ - tsconfig: tsConfigPath - })); }