From f418204583a65fff875c149e1f63e5cb1f814401 Mon Sep 17 00:00:00 2001 From: Andreas Fernandez <a.fernandez@scripting-base.de> Date: Thu, 23 Jan 2020 12:30:39 +0100 Subject: [PATCH] [TASK] Improve consecutive build performance To improve the consecutive build experience, several caches now kick in to only lint and compile files that are necessary. Following changes are done in this patch: - added cache for eslint - build TypeScript incremental - don't mangle TypeScript twice in a full build To be able to utilize the `--incremental` feature of TypeScript, generated files are not removed anymore before a build, since TypeScript needs the previously compiled files for comparision. The `tsclean` grunt task has been renamed to `clear-build` and is now executed right before any *full* build. Side note: on the patch authors machine, the command `grunt scripts` went from ~30 seconds to ~8 seconds after second invokation. Resolves: #90187 Releases: master Change-Id: I2a6cc204aa059411b4d0b26e2e153ff944d190ad Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63019 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Richard Haeser <richard@maxserv.com> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Richard Haeser <richard@maxserv.com> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> --- Build/Gruntfile.js | 34 ++++++++++++++++++++++++---------- Build/tsconfig.json | 2 ++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Build/Gruntfile.js b/Build/Gruntfile.js index 2271b8273677..e88e525fc137 100644 --- a/Build/Gruntfile.js +++ b/Build/Gruntfile.js @@ -187,6 +187,8 @@ module.exports = function (grunt) { }, eslint: { options: { + cache: true, + cacheLocation: './.cache/eslintcache/', configFile: 'eslintrc.js' }, files: { @@ -632,28 +634,40 @@ module.exports = function (grunt) { */ grunt.registerTask('update', ['exec:yarn-install', 'npmcopy']); + /** + * grunt compile-typescript task + * + * call "$ grunt compile-typescript" + * + * This task does the following things: + * - 1) Check all TypeScript files (*.ts) with ESLint which are located in sysext/<EXTKEY>/Resources/Private/TypeScript/*.ts + * - 2) Compiles all TypeScript files (*.ts) which are located in sysext/<EXTKEY>/Resources/Private/TypeScript/*.ts + */ + grunt.registerTask('compile-typescript', ['tsconfig', 'eslint', 'exec:ts']); + /** * grunt scripts task * * call "$ grunt scripts" * * this task does the following things: - * - 1) Check all TypeScript files (*.ts) with ESLint which are located in sysext/<EXTKEY>/Resources/Private/TypeScript/*.ts - * - 2) Compiles all TypeScript files (*.ts) which are located in sysext/<EXTKEY>/Resources/Private/TypeScript/*.ts - * - 3) Copy all generated JavaScript and Map files to public folders + * - 1) Compiles TypeScript (see compile-typescript) + * - 2) Copy all generated JavaScript files to public folders + * - 3) Minify build */ - grunt.registerTask('scripts', ['tsconfig', 'eslint', 'tsclean', 'exec:ts', 'copy:ts_files', 'terser:typescript']); + grunt.registerTask('scripts', ['compile-typescript', 'copy:ts_files', 'terser:typescript']); /** - * grunt tsclean task + * grunt clear-build task * - * call "$ grunt tsclean" + * call "$ grunt clear-build" * - * Clean the JavaScript output folder before building + * Removes all build-related assets, e.g. cache and built files */ - grunt.task.registerTask('tsclean', function () { + grunt.registerTask('clear-build', function () { grunt.option('force'); - grunt.file.delete("JavaScript"); + grunt.file.delete('.cache'); + grunt.file.delete('JavaScript'); }); /** @@ -693,5 +707,5 @@ module.exports = function (grunt) { * - minifies svg files * - compiles TypeScript files */ - grunt.registerTask('build', ['update', 'scripts', 'copy', 'format', 'css', 'terser', 'imagemin']); + grunt.registerTask('build', ['clear-build', 'update', 'compile-typescript', 'copy', 'format', 'css', 'terser', 'imagemin']); }; diff --git a/Build/tsconfig.json b/Build/tsconfig.json index 6838f62ef6c9..4608a25b22ed 100644 --- a/Build/tsconfig.json +++ b/Build/tsconfig.json @@ -10,6 +10,8 @@ "es2018", "es2019" ], + "incremental": true, + "tsBuildInfoFile": "./.cache/tsconfig.tsbuildinfo", "module": "amd", "sourceMap": false, "removeComments": false, -- GitLab