Browse Source

fix(dashboard): Allow reading tsconfig files with comments

Michael Bromley 3 months ago
parent
commit
c5c7646f27

+ 27 - 1
package-lock.json

@@ -50984,7 +50984,7 @@
         "dotenv": "^16.4.5",
         "fs-extra": "^11.2.0",
         "picocolors": "^1.0.0",
-        "strip-json-comments": "^5.0.2",
+        "strip-json-comments": "^5.0.3",
         "ts-morph": "^21.0.1",
         "ts-node": "^10.9.2",
         "tsconfig-paths": "^4.2.0"
@@ -51292,6 +51292,7 @@
         "react-resizable-panels": "^3.0.3",
         "recharts": "^2.15.4",
         "sonner": "^2.0.6",
+        "strip-json-comments": "^5.0.3",
         "tailwind-merge": "^3.2.0",
         "tailwindcss": "^4.1.5",
         "tailwindcss-animate": "^1.0.7",
@@ -51358,6 +51359,19 @@
         "url": "https://github.com/sponsors/sindresorhus"
       }
     },
+    "packages/dashboard/node_modules/@eslint/eslintrc/node_modules/strip-json-comments": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
+      "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=8"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
     "packages/dashboard/node_modules/@types/node": {
       "version": "22.18.8",
       "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.8.tgz",
@@ -51593,6 +51607,18 @@
         "node": ">=8"
       }
     },
+    "packages/dashboard/node_modules/strip-json-comments": {
+      "version": "5.0.3",
+      "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz",
+      "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=14.16"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
     "packages/dev-server": {
       "version": "3.4.3",
       "license": "GPL-3.0-or-later",

+ 1 - 1
packages/cli/package.json

@@ -43,7 +43,7 @@
         "dotenv": "^16.4.5",
         "fs-extra": "^11.2.0",
         "picocolors": "^1.0.0",
-        "strip-json-comments": "^5.0.2",
+        "strip-json-comments": "^5.0.3",
         "ts-morph": "^21.0.1",
         "ts-node": "^10.9.2",
         "tsconfig-paths": "^4.2.0"

+ 1 - 0
packages/dashboard/package.json

@@ -134,6 +134,7 @@
     "react-resizable-panels": "^3.0.3",
     "recharts": "^2.15.4",
     "sonner": "^2.0.6",
+    "strip-json-comments": "^5.0.3",
     "tailwind-merge": "^3.2.0",
     "tailwindcss": "^4.1.5",
     "tailwindcss-animate": "^1.0.7",

+ 2 - 1
packages/dashboard/vite/utils/tsconfig-utils.ts

@@ -1,5 +1,6 @@
 import fs from 'fs-extra';
 import path from 'path';
+import stripJsonComments from 'strip-json-comments';
 import { CompilerOptions } from 'typescript';
 
 import { Logger, TransformTsConfigPathMappingsFn } from '../types.js';
@@ -56,7 +57,7 @@ export async function findTsConfigPaths(
 
 async function getCompilerOptionsFromFile(tsConfigFilePath: string): Promise<CompilerOptions> {
     const tsConfigContent = await fs.readFile(tsConfigFilePath, 'utf-8');
-    const tsConfig = JSON.parse(tsConfigContent);
+    const tsConfig = JSON.parse(stripJsonComments(tsConfigContent));
     return tsConfig.compilerOptions || {};
 }