Skip to content

Commit

Permalink
enable experimentalFileCaching by default (#885)
Browse files Browse the repository at this point in the history
* enable experimentalFileCaching by default

* update changelog
  • Loading branch information
johnnyreilly committed Dec 21, 2018
1 parent cf6b2d3 commit 9851e3c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions 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!
Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -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<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; } )_

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).
Expand Down Expand Up @@ -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)_

Expand Down
1 change: 1 addition & 0 deletions examples/thread-loader/webpack.config.js
Expand Up @@ -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
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -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>,
loaderOptions
);
Expand Down
2 changes: 2 additions & 0 deletions test/comparison-tests/run-tests.js
Expand Up @@ -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;
Expand Down

0 comments on commit 9851e3c

Please sign in to comment.