From 54eec739dcce488d9e24e5e2abc662794e745436 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Sat, 20 Nov 2021 03:48:17 +0300 Subject: [PATCH] chore: add an ption to turn off TSC check step This also speeds up the recompilation times, since TSC is now used only if the output is missing or the typescript files are changed. --- CMakeLists.txt | 9 +++++++++ src/kwinscript/CMakeLists.txt | 16 ++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f9891e7..f4eab650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,15 @@ cmake_minimum_required(VERSION 3.16) project(bismuth) +option( + USE_TSC + "Use TypeScript Compler to check the code before bundling \ + using esbuild. This could be useful, if you know, that the \ + code is correct and you want to speed up building times. \ + For example - you are a packager." + ON +) + set(QT_MIN_VERSION "5.15.0") set(KF5_MIN_VERSION "5.80.0") diff --git a/src/kwinscript/CMakeLists.txt b/src/kwinscript/CMakeLists.txt index 55a201e6..106a2d8e 100644 --- a/src/kwinscript/CMakeLists.txt +++ b/src/kwinscript/CMakeLists.txt @@ -23,24 +23,20 @@ add_custom_target( file(GLOB_RECURSE TYPESCRIPT_SOURCES CONFIGURE_DEPENDS "*.ts") +if(USE_TSC) + set(TSC_COMMAND "npx" "tsc" "--noEmit" "--incremental") +endif() + add_custom_command( OUTPUT "bismuth/contents/code/index.mjs" + COMMAND ${TSC_COMMAND} COMMAND "npx" "esbuild" "--bundle" "${CMAKE_CURRENT_SOURCE_DIR}/index.ts" "--outfile=${CMAKE_CURRENT_BINARY_DIR}/bismuth/contents/code/index.mjs" "--format=esm" "--platform=neutral" - DEPENDS - LintViaTSC - ${TYPESCRIPT_SOURCES} - COMMENT "🎁 Bundling using esbuild..." -) - -add_custom_target( - LintViaTSC - COMMAND "npx" "tsc" "--noEmit" "--incremental" - COMMENT "👮 Checking sources using TS Compiler..." DEPENDS ${TYPESCRIPT_SOURCES} + COMMENT "🏗️ Compiling and bundling TypeScirpt sources..." ) add_custom_command(