Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 1398179

Browse files
DimitarTachevrosen-vladimirov
authored andcommitted
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. (#926)
1 parent ccbf8de commit 1398179

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Diff for: templates/webpack.typescript.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)