From 185e04fa8d97ebb03a04236d786c27ecb0834373 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Dec 2018 06:09:05 +0000 Subject: [PATCH 1/2] enable experimentalFileCaching by default --- README.md | 10 +++++----- examples/thread-loader/webpack.config.js | 1 + package.json | 2 +- src/index.ts | 2 +- test/comparison-tests/run-tests.js | 2 ++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dd3e8f395..bdf4e2070 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,8 @@ It's advisable to use this with the [fork-ts-checker-webpack-plugin](https://git This will ensure that the plugin checks for both syntactic errors (eg `const array = [{} {}];`) and semantic errors (eg `const x: number = '1';`). By default the plugin only checks for semantic errors (as when used with ts-loader in `transpileOnly` mode, ts-loader will still report syntactic errors). +Also, if you are using `thread-loader` in watch mode, remember to set `poolTimeout: Infinity` so workers don't die. + #### getCustomTransformers _( () => { before?: TransformerFactory[]; after?: TransformerFactory[]; } )_ Provide custom transformers - only compatible with TypeScript 2.3+ (and 2.4 if using `transpileOnly` mode). For example usage take a look at [typescript-plugin-styled-components](https://github.com/Igorbek/typescript-plugin-styled-components) or our [test](test/comparison-tests/customTransformer). @@ -543,14 +545,12 @@ Extending `tsconfig.json`: Note that changes in the extending file while not be respected by `ts-loader`. Its purpose is to satisfy the code editor. -#### experimentalFileCaching _(boolean) (default=false)_ +#### experimentalFileCaching _(boolean) (default=true)_ -By default whenever the TypeScript compiler needs to check that a file/directory exists or resolve symlinks it makes syscalls. -It does not cache the result of these operations and this may result in many syscalls with the same arguments ([see comment](https://github.com/TypeStrong/ts-loader/issues/825#issue-354725524) with example). +By default whenever the TypeScript compiler needs to check that a file/directory exists or resolve symlinks it makes syscalls. It does not cache the result of these operations and this may result in many syscalls with the same arguments ([see comment](https://github.com/TypeStrong/ts-loader/issues/825#issue-354725524) with example). In some cases it may produce performance degradation. -This flag enables caching for some FS-functions like `fileExists`, `realpath` and `directoryExists` for TypeScript compiler. -Note that caches are cleared between compilations. +This flag enables caching for some FS-functions like `fileExists`, `realpath` and `directoryExists` for TypeScript compiler. Note that caches are cleared between compilations. #### projectReferences _(boolean) (default=false)_ diff --git a/examples/thread-loader/webpack.config.js b/examples/thread-loader/webpack.config.js index 7f5e6d314..727582e60 100644 --- a/examples/thread-loader/webpack.config.js +++ b/examples/thread-loader/webpack.config.js @@ -17,6 +17,7 @@ module.exports = { options: { // there should be 1 cpu for the fork-ts-checker-webpack-plugin workers: require('os').cpus().length - 1, + poolTimeout: Infinity // set this to Infinity in watch mode - see https://github.com/webpack-contrib/thread-loader }, }, { diff --git a/package.json b/package.json index 996cdc2fa..6f2660c7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "5.3.1", + "version": "5.3.2", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist/types/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 2fe667793..62339c30a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -313,7 +313,7 @@ function makeLoaderOptions(instanceName: string, loaderOptions: LoaderOptions) { // When the watch API usage stabilises look to remove this option and make watch usage the default behaviour when available experimentalWatchApi: false, allowTsInNodeModules: false, - experimentalFileCaching: false + experimentalFileCaching: true } as Partial, loaderOptions ); diff --git a/test/comparison-tests/run-tests.js b/test/comparison-tests/run-tests.js index 794bbc09c..625b47e1d 100644 --- a/test/comparison-tests/run-tests.js +++ b/test/comparison-tests/run-tests.js @@ -123,12 +123,14 @@ function runTestAsChildProcess(testName) { testCommand + (saveOutputMode ? ' --save-output' : ''), { stdio: 'inherit' } ); + /* No longer necessary and experimentalFileCaching is enabled by default - approach may prove useful in future though if (!saveOutputMode) { const _testOutput2 = execSync( testCommand + ' --extra-option experimentalFileCaching', { stdio: 'inherit' } ); } + */ return true; } catch (err) { return false; From cf58dccfffd5597c151c5187f7ae69d201aa9057 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Dec 2018 07:09:37 +0000 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c14dca3..d23d11cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.3.2 + +* [feat: enable experimentalFileCaching by default](https://github.com/TypeStrong/ts-loader/pull/885) (#868) - thanks @timocov! + ## v5.3.1 * [fix: projectReferences with rootDir](https://github.com/TypeStrong/ts-loader/pull/871) (#868) - thanks @andrewbranch!