From ca45fd93c14f9f03cdecabd47a7e4b67ff001a12 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 7 Aug 2024 20:10:20 +0800 Subject: [PATCH] Remove tsconfig-resolver from repo (#11642) --- pnpm-lock.yaml | 40 +++------------------------------------- scripts/package.json | 2 +- scripts/smoke/check.js | 28 ++++++++++------------------ 3 files changed, 14 insertions(+), 56 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 439bb54769..a7b0a33ec2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5940,9 +5940,9 @@ importers: execa: specifier: ^8.0.1 version: 8.0.1 - tsconfig-resolver: - specifier: ^3.0.1 - version: 3.0.1 + tsconfck: + specifier: ^3.1.1 + version: 3.1.1(typescript@5.5.4) packages: @@ -7370,9 +7370,6 @@ packages: '@types/js-yaml@4.0.9': resolution: {integrity: sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==} - '@types/json5@0.0.30': - resolution: {integrity: sha512-sqm9g7mHlPY/43fcSNrCYfOeX9zkTTK+euO5E6+CVijSMm5tTjkVdwdqRkY3ljjIAf8679vps5jKUoJBCLsMDA==} - '@types/katex@0.16.7': resolution: {integrity: sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==} @@ -7442,9 +7439,6 @@ packages: '@types/relateurl@0.2.33': resolution: {integrity: sha512-bTQCKsVbIdzLqZhLkF5fcJQreE4y1ro4DIyVrlDNSCJRRwHhB8Z+4zXXa8jN6eDvc2HbRsEYgbvrnGvi54EpSw==} - '@types/resolve@1.20.6': - resolution: {integrity: sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==} - '@types/sax@1.2.7': resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} @@ -10844,10 +10838,6 @@ packages: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} - strip-bom@4.0.0: - resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} - engines: {node: '>=8'} - strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -11052,9 +11042,6 @@ packages: typescript: optional: true - tsconfig-resolver@3.0.1: - resolution: {integrity: sha512-ZHqlstlQF449v8glscGRXzL6l2dZvASPCdXJRWG4gHEZlUVx2Jtmr+a2zeVG4LCsKhDXKRj5R3h0C/98UcVAQg==} - tslib@2.1.0: resolution: {integrity: sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==} @@ -11099,10 +11086,6 @@ packages: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} - type-fest@0.13.1: - resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==} - engines: {node: '>=10'} - type-fest@1.4.0: resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==} engines: {node: '>=10'} @@ -13230,8 +13213,6 @@ snapshots: '@types/js-yaml@4.0.9': {} - '@types/json5@0.0.30': {} - '@types/katex@0.16.7': {} '@types/linkify-it@5.0.0': {} @@ -13299,8 +13280,6 @@ snapshots: '@types/relateurl@0.2.33': {} - '@types/resolve@1.20.6': {} - '@types/sax@1.2.7': dependencies: '@types/node': 18.19.31 @@ -17367,8 +17346,6 @@ snapshots: strip-bom@3.0.0: {} - strip-bom@4.0.0: {} - strip-final-newline@3.0.0: {} strip-json-comments@3.1.1: {} @@ -17592,15 +17569,6 @@ snapshots: optionalDependencies: typescript: 5.5.4 - tsconfig-resolver@3.0.1: - dependencies: - '@types/json5': 0.0.30 - '@types/resolve': 1.20.6 - json5: 2.2.3 - resolve: 1.22.8 - strip-bom: 4.0.0 - type-fest: 0.13.1 - tslib@2.1.0: {} tslib@2.6.2: {} @@ -17636,8 +17604,6 @@ snapshots: dependencies: prelude-ls: 1.2.1 - type-fest@0.13.1: {} - type-fest@1.4.0: {} type-fest@2.19.0: {} diff --git a/scripts/package.json b/scripts/package.json index b085b6b65f..12bf98b79b 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -22,6 +22,6 @@ "del": "^7.1.0", "esbuild-plugin-copy": "^2.1.1", "execa": "^8.0.1", - "tsconfig-resolver": "^3.0.1" + "tsconfck": "^3.1.1" } } diff --git a/scripts/smoke/check.js b/scripts/smoke/check.js index 9a501de3ee..9f00384681 100644 --- a/scripts/smoke/check.js +++ b/scripts/smoke/check.js @@ -4,7 +4,7 @@ import { spawn } from 'node:child_process'; import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'; import * as path from 'node:path'; import pLimit from 'p-limit'; -import { tsconfigResolverSync } from 'tsconfig-resolver'; +import { toJson } from 'tsconfck'; const skippedExamples = ['toolbar-app', 'component', 'server-islands']; @@ -70,25 +70,17 @@ function checkExamples() { */ function prepareExample(examplePath) { const tsconfigPath = path.join('./examples/', examplePath, 'tsconfig.json'); - const tsconfig = tsconfigResolverSync({ filePath: tsconfigPath, cache: false }); - let originalConfig = undefined; + if (!existsSync(tsconfigPath)) return + + const originalConfig = readFileSync(tsconfigPath, 'utf-8'); + const tsconfig = JSON.parse(toJson(originalConfig)); - if (tsconfig.exists) { - tsconfig.config.extends = 'astro/tsconfigs/strictest'; - originalConfig = readFileSync(tsconfigPath).toString(); + // Swap to strictest config to make sure it also passes + tsconfig.extends = 'astro/tsconfigs/strictest'; + tsconfig.compilerOptions ??= {} + tsconfig.compilerOptions.types = tsconfig.compilerOptions.types ?? []; // Speeds up tests - if (!tsconfig.config.compilerOptions) { - tsconfig.config.compilerOptions = {}; - } - - tsconfig.config.compilerOptions = Object.assign(tsconfig.config.compilerOptions, { - types: tsconfig.config.compilerOptions.types ?? [], // Speeds up tests - }); - } - - if (tsconfig.config) { - writeFileSync(tsconfigPath, JSON.stringify(tsconfig.config)); - } + writeFileSync(tsconfigPath, JSON.stringify(tsconfig)); return originalConfig; }