From 426a1d2cb3d2108ce7dd19f0d136b6ae041e982a Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Sat, 19 Jan 2019 20:54:11 +0100 Subject: [PATCH 1/3] feat(ts-config-webpack-plugin): Increase incremental type checking performance with `useTypescriptIncrementalApi` fixes #39 --- .../test/fixtures/simple/tsconfig.json | 3 +-- packages/scss-config-webpack-plugin/tsconfig.json | 7 +++++++ .../config/development.config.js | 15 +++++++++------ .../config/production.config.js | 3 +++ packages/ts-config-webpack-plugin/package.json | 2 +- performance/measure-dev-server.js | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 packages/scss-config-webpack-plugin/tsconfig.json diff --git a/packages/common-config-webpack-plugin/test/fixtures/simple/tsconfig.json b/packages/common-config-webpack-plugin/test/fixtures/simple/tsconfig.json index 4971150..c8200e2 100644 --- a/packages/common-config-webpack-plugin/test/fixtures/simple/tsconfig.json +++ b/packages/common-config-webpack-plugin/test/fixtures/simple/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "sourceMap": true, - "skipLibCheck": true, - "suppressOutputPathCheck": true + "skipLibCheck": true } } diff --git a/packages/scss-config-webpack-plugin/tsconfig.json b/packages/scss-config-webpack-plugin/tsconfig.json new file mode 100644 index 0000000..1943e5d --- /dev/null +++ b/packages/scss-config-webpack-plugin/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + "rootDir": "./" + } +} diff --git a/packages/ts-config-webpack-plugin/config/development.config.js b/packages/ts-config-webpack-plugin/config/development.config.js index 9665631..ab3ad8b 100644 --- a/packages/ts-config-webpack-plugin/config/development.config.js +++ b/packages/ts-config-webpack-plugin/config/development.config.js @@ -4,10 +4,8 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const cpus = os.cpus().length; -// we use - 2 workers for quadcore cpus and higher, two cpus are reserved -// for the ts checker plugin (which at least needs one). -const tsLoaderWorkers = cpus > 3 ? cpus - 2 : 1; -const forkTsCheckerWorkers = Math.max(1, cpus - tsLoaderWorkers); +// we use - 1 workers for tricore cpus and higher, one cpu will be preserved +const tsLoaderWorkers = cpus > 2 ? cpus - 1 : 1; /** * Common Development Config @@ -65,12 +63,17 @@ exports = module.exports = (options) => ({ new ForkTsCheckerWebpackPlugin({ // don't block webpack's emit to wait for type checker, errors only visible inside CLI async: true, - // increase performance on multicore systems - workers: forkTsCheckerWorkers, // checkSyntacticErrors is required as we use happyPackMode and the thread-loader to parallelise the builds checkSyntacticErrors: true, // Set the tsconfig.json path tsconfig: options.configFile, + // Make use of a new API comming with TypeScript 2.7 + // which allows to speed up the type checking + // https://github.com/namics/webpack-config-plugins/issues/39 + useTypescriptIncrementalApi: true, + // To allow using this plugin even if there is no .ts or .tsx file + // ignore "TS18003: No inputs were found in config file" + ignoreDiagnostics: [18003], }), ], }); diff --git a/packages/ts-config-webpack-plugin/config/production.config.js b/packages/ts-config-webpack-plugin/config/production.config.js index 404a7b9..d316c9b 100644 --- a/packages/ts-config-webpack-plugin/config/production.config.js +++ b/packages/ts-config-webpack-plugin/config/production.config.js @@ -68,6 +68,9 @@ exports = module.exports = (options) => ({ checkSyntacticErrors: true, // Set the tsconfig.json path tsconfig: options.configFile, + // To allow using this plugin even if there is no .ts or .tsx file + // ignore "TS18003: No inputs were found in config file" + ignoreDiagnostics: [18003], }), ], }); diff --git a/packages/ts-config-webpack-plugin/package.json b/packages/ts-config-webpack-plugin/package.json index 9211d3a..3be3302 100644 --- a/packages/ts-config-webpack-plugin/package.json +++ b/packages/ts-config-webpack-plugin/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "cache-loader": "^1.2.2", - "fork-ts-checker-webpack-plugin": "^0.5.2", + "fork-ts-checker-webpack-plugin": "1.0.0-alpha.4", "thread-loader": "^2.1.1", "ts-loader": "^5.3.1", "tslint": "^5.12.0" diff --git a/performance/measure-dev-server.js b/performance/measure-dev-server.js index 2288ef9..db91a8c 100644 --- a/performance/measure-dev-server.js +++ b/performance/measure-dev-server.js @@ -92,7 +92,7 @@ async function launchWebpackDevServer(args, environmentName, onReady) { await rimrafAsync('./profiles'); // Configs as in webpack.config.NAME.js - const environments = ['current', 'latest']; + const environments = ['latest', 'current']; const results = {}; let generatedComponentCount; From cea119c269f4fe1eb882ad4c43cd23fd172fbb6d Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Sun, 20 Jan 2019 11:20:38 +0100 Subject: [PATCH 2/3] chore(performance-tests): Add additional pause after initial build --- performance/measure-dev-server.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/performance/measure-dev-server.js b/performance/measure-dev-server.js index db91a8c..8acd768 100644 --- a/performance/measure-dev-server.js +++ b/performance/measure-dev-server.js @@ -73,6 +73,11 @@ async function launchWebpackDevServer(args, environmentName, onReady) { process.hrtime(startTime)[0] + Math.round(process.hrtime(startTime)[1] / 1000000) / 1000; timings.push(elapsed); } + if (runs === 0) { + // Wait for the initial build to be done + // including garbage collection + await sleep(10000); + } // Wait for a moment to prevent running into thresholds await sleep(3500); runs++; From 23883c40b59d9ab10cda3f33ad049c39612a3954 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Sun, 20 Jan 2019 12:57:00 +0100 Subject: [PATCH 3/3] DONT MERGE - Try OSX Build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c748f7e..efa6171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: node_js sudo: false os: - - linux + - osx node_js: - 'node'