Skip to content

Commit 9851e3c

Browse files
authored
enable experimentalFileCaching by default (#885)
* enable experimentalFileCaching by default * update changelog
1 parent cf6b2d3 commit 9851e3c

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v5.3.2
4+
5+
* [feat: enable experimentalFileCaching by default](https://github.com/TypeStrong/ts-loader/pull/885) (#868) - thanks @timocov!
6+
37
## v5.3.1
48

59
* [fix: projectReferences with rootDir](https://github.com/TypeStrong/ts-loader/pull/871) (#868) - thanks @andrewbranch!

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ It's advisable to use this with the [fork-ts-checker-webpack-plugin](https://git
248248

249249
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).
250250

251+
Also, if you are using `thread-loader` in watch mode, remember to set `poolTimeout: Infinity` so workers don't die.
252+
251253
#### getCustomTransformers _( () => { before?: TransformerFactory<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; } )_
252254

253255
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`:
543545

544546
Note that changes in the extending file while not be respected by `ts-loader`. Its purpose is to satisfy the code editor.
545547

546-
#### experimentalFileCaching _(boolean) (default=false)_
548+
#### experimentalFileCaching _(boolean) (default=true)_
547549

548-
By default whenever the TypeScript compiler needs to check that a file/directory exists or resolve symlinks it makes syscalls.
549-
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).
550+
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).
550551
In some cases it may produce performance degradation.
551552

552-
This flag enables caching for some FS-functions like `fileExists`, `realpath` and `directoryExists` for TypeScript compiler.
553-
Note that caches are cleared between compilations.
553+
This flag enables caching for some FS-functions like `fileExists`, `realpath` and `directoryExists` for TypeScript compiler. Note that caches are cleared between compilations.
554554

555555
#### projectReferences _(boolean) (default=false)_
556556

examples/thread-loader/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
options: {
1818
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
1919
workers: require('os').cpus().length - 1,
20+
poolTimeout: Infinity // set this to Infinity in watch mode - see https://github.com/webpack-contrib/thread-loader
2021
},
2122
},
2223
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "5.3.1",
3+
"version": "5.3.2",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist/types/index.d.ts",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function makeLoaderOptions(instanceName: string, loaderOptions: LoaderOptions) {
313313
// When the watch API usage stabilises look to remove this option and make watch usage the default behaviour when available
314314
experimentalWatchApi: false,
315315
allowTsInNodeModules: false,
316-
experimentalFileCaching: false
316+
experimentalFileCaching: true
317317
} as Partial<LoaderOptions>,
318318
loaderOptions
319319
);

test/comparison-tests/run-tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ function runTestAsChildProcess(testName) {
123123
testCommand + (saveOutputMode ? ' --save-output' : ''),
124124
{ stdio: 'inherit' }
125125
);
126+
/* No longer necessary and experimentalFileCaching is enabled by default - approach may prove useful in future though
126127
if (!saveOutputMode) {
127128
const _testOutput2 = execSync(
128129
testCommand + ' --extra-option experimentalFileCaching',
129130
{ stdio: 'inherit' }
130131
);
131132
}
133+
*/
132134
return true;
133135
} catch (err) {
134136
return false;

0 commit comments

Comments
 (0)