From a19523525bc72b67e4276ca1d9b5f072f6535425 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Fri, 20 Sep 2024 09:21:23 +0200 Subject: [PATCH] feat: build command (tsc prod build) now uses ts5.6's `--noCheck` for performance gain. --- src/bin/dev-lib.ts | 21 +++++++++------------ src/build.util.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/bin/dev-lib.ts b/src/bin/dev-lib.ts index bb57b8a..ee5d532 100755 --- a/src/bin/dev-lib.ts +++ b/src/bin/dev-lib.ts @@ -27,31 +27,28 @@ interface Command { const commands: (Command | Separator)[] = [ new Separator(), // build + { + name: 'tsc', + fn: tscAll, + desc: 'Run tsc in folders (src, scripts, e2e, playwright) if there is tsconfig.json present', + }, + { name: 'bt', fn: bt, desc: 'Build & Test: run "tsc" and then "test".' }, + { name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".' }, { name: 'build', fn: buildProd, - desc: 'Clean ./dist, run "build-copy" then tsc with emit, using tsconfig.prod.json', - cliOnly: true, + desc: 'Clean ./dist, run "build-copy" then tsc with --emit and --noCheck, using tsconfig.prod.json', }, { name: 'build-copy', fn: buildCopy, desc: 'Copy the non-ts files from ./src to ./dist', - cliOnly: true, }, { name: 'build-esm-cjs', fn: buildEsmCjs, - desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes.', - cliOnly: true, - }, - { - name: 'tsc', - fn: tscAll, - desc: 'Run tsc in folders (src, scripts, e2e, playwright) if there is tsconfig.json present', + desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes, with --emit and --noCheck', }, - { name: 'bt', fn: bt, desc: 'Build & Test: run "build" and then "test".' }, - { name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "build", then "test".' }, new Separator(), // test { name: 'test', fn: runJest, desc: 'Run jest for *.test.ts files.' }, { diff --git a/src/build.util.ts b/src/build.util.ts index 7a7392a..c978a66 100644 --- a/src/build.util.ts +++ b/src/build.util.ts @@ -30,6 +30,9 @@ export async function buildEsmCjs(): Promise { 'nodenext', '--moduleResolution', 'nodenext', + '--noEmit', + 'false', + '--noCheck', ], shell: false, }), @@ -45,6 +48,9 @@ export async function buildEsmCjs(): Promise { 'bundler', '--declaration', 'false', + '--noEmit', + 'false', + '--noCheck', ], shell: false, }), @@ -89,11 +95,11 @@ export async function runTSCInFolder(tsconfigPath: string, args: string[] = []): }) } -export async function runTSCProd(): Promise { +export async function runTSCProd(args: string[] = []): Promise { const tsconfigPath = [`./tsconfig.prod.json`].find(p => fs.existsSync(p)) || 'tsconfig.json' await exec2.spawnAsync(`tsc`, { - args: ['-P', tsconfigPath], + args: ['-P', tsconfigPath, '--noEmit', 'false', '--noCheck', ...args], shell: false, }) }