From 2daface80543ce3d1599761018f2f9375cb97741 Mon Sep 17 00:00:00 2001 From: Gregory Joseph Date: Fri, 13 Dec 2024 16:14:54 +1100 Subject: [PATCH 1/3] Align tsconfig.json files * order of elements but also values: * module: nodeNext, moduleResolution: nodeNext, esModuleInterop: true, resolveJsonModule: true * tichu-term-client still uses commonjs for now (#829) --- .../tichu-client-ts-lib/tsconfig.json | 19 ++++++++++------- .../packages/tichu-term-client/tsconfig.json | 19 ++++++++++------- .../packages/tichu-web/tsconfig.json | 21 +++++++++++++------ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/tichu-clients/packages/tichu-client-ts-lib/tsconfig.json b/tichu-clients/packages/tichu-client-ts-lib/tsconfig.json index 70f72c498..046c3d479 100644 --- a/tichu-clients/packages/tichu-client-ts-lib/tsconfig.json +++ b/tichu-clients/packages/tichu-client-ts-lib/tsconfig.json @@ -1,19 +1,22 @@ { "compilerOptions": { - "target": "es2023", // when we had es2019, we left a comment to say that: Node doesn't understand nullish coalescing or optional chaining, so instruct ts to transpile + "target": "es2023", "module": "nodenext", + "moduleResolution": "nodenext", + "esModuleInterop": true, + "resolveJsonModule": true, "lib": ["es2023", "dom"], + "types": ["node", "fs-extra"], + + "allowJs": false, "declaration": true, "declarationMap": true, "experimentalDecorators": true, - "outDir": "./lib", - "rootDir": "./src", + "importHelpers": true, "strict": true, - "types": ["node", "fs-extra"], - "esModuleInterop": false, - "moduleResolution": "nodenext", - "resolveJsonModule": true, - "importHelpers": true + + "outDir": "./lib", + "rootDir": "./src" }, "exclude": ["node_modules", "lib", "templates"] } diff --git a/tichu-clients/packages/tichu-term-client/tsconfig.json b/tichu-clients/packages/tichu-term-client/tsconfig.json index 6f458dab5..8b0b1c43c 100644 --- a/tichu-clients/packages/tichu-term-client/tsconfig.json +++ b/tichu-clients/packages/tichu-term-client/tsconfig.json @@ -1,19 +1,22 @@ { "compilerOptions": { - "target": "es2023", // when we had es2019, we left a comment to say that: Node doesn't understand nullish coalescing or optional chaining, so instruct ts to transpile + "target": "es2023", "module": "commonjs", + "moduleResolution": "node", + "esModuleInterop": true, + "resolveJsonModule": true, "lib": ["es2023", "dom"], + "types": ["node", "fs-extra"], + + "allowJs": false, "declaration": true, "declarationMap": true, "experimentalDecorators": true, - "outDir": "./lib", - "rootDir": "./src", + "importHelpers": true, "strict": true, - "types": ["node", "fs-extra"], - "esModuleInterop": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "importHelpers": true + + "outDir": "./lib", + "rootDir": "./src" }, "exclude": ["node_modules", "lib", "templates"] } diff --git a/tichu-clients/packages/tichu-web/tsconfig.json b/tichu-clients/packages/tichu-web/tsconfig.json index 45a191142..6fd4f4594 100644 --- a/tichu-clients/packages/tichu-web/tsconfig.json +++ b/tichu-clients/packages/tichu-web/tsconfig.json @@ -1,18 +1,27 @@ { "compilerOptions": { "target": "es2023", + "module": "nodenext", + "moduleResolution": "nodenext", + "esModuleInterop": true, + "resolveJsonModule": true, "lib": ["dom", "dom.iterable", "esnext"], "types": ["vite/client", "vite-plugin-svgr/client"], - "allowJs": true, + + "allowJs": false, + "declaration": true, + "declarationMap": true, + "experimentalDecorators": true, + "importHelpers": true, + "strict": true, + + "outDir": "./lib", + "rootDir": "./src", + "skipLibCheck": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "module": "nodenext", - "moduleResolution": "nodenext", - "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx" From 32344d767fe2440cd431a389fbfd95e838eebccd Mon Sep 17 00:00:00 2001 From: Gregory Joseph Date: Fri, 13 Dec 2024 16:37:58 +1100 Subject: [PATCH 2/3] With allowJs:false in tsconfig, we needed to rename test/setup.js to .ts --- .../packages/tichu-web/src/test/{setup.js => setup.ts} | 0 tichu-clients/packages/tichu-web/vite.config.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tichu-clients/packages/tichu-web/src/test/{setup.js => setup.ts} (100%) diff --git a/tichu-clients/packages/tichu-web/src/test/setup.js b/tichu-clients/packages/tichu-web/src/test/setup.ts similarity index 100% rename from tichu-clients/packages/tichu-web/src/test/setup.js rename to tichu-clients/packages/tichu-web/src/test/setup.ts diff --git a/tichu-clients/packages/tichu-web/vite.config.ts b/tichu-clients/packages/tichu-web/vite.config.ts index d6b868cec..383d88745 100644 --- a/tichu-clients/packages/tichu-web/vite.config.ts +++ b/tichu-clients/packages/tichu-web/vite.config.ts @@ -25,6 +25,6 @@ export default defineConfig({ test: { environment: "jsdom", globals: false, // this is the default and I agree -- let's use explicit imports instead - setupFiles: "./src/test/setup.js", + setupFiles: "./src/test/setup.ts", }, }); From 88f4ea07ca68ea6d274f79d0ba5c7071725b4485 Mon Sep 17 00:00:00 2001 From: Gregory Joseph Date: Fri, 13 Dec 2024 16:38:27 +1100 Subject: [PATCH 3/3] unrelated: remove cruft from vite.config, now builds in dist/ instead of build/ --- tichu-clients/.gitignore | 1 + tichu-clients/packages/tichu-web/vite.config.ts | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tichu-clients/.gitignore b/tichu-clients/.gitignore index a357214c8..6ed066528 100644 --- a/tichu-clients/.gitignore +++ b/tichu-clients/.gitignore @@ -2,6 +2,7 @@ node_modules/ lib/ build/ +dist/ storybook-static/ *.local *.log diff --git a/tichu-clients/packages/tichu-web/vite.config.ts b/tichu-clients/packages/tichu-web/vite.config.ts index 383d88745..3e8c702fb 100644 --- a/tichu-clients/packages/tichu-web/vite.config.ts +++ b/tichu-clients/packages/tichu-web/vite.config.ts @@ -3,15 +3,9 @@ import reactRefresh from "@vitejs/plugin-react"; // import eslint from "vite-plugin-eslint"; import svgrPlugin from "vite-plugin-svgr"; -// https://vitejs.dev/config/ export default defineConfig({ - // This changes the out put dir from dist to build - // comment this out if that isn't relevant for your project - build: { - outDir: "build", - }, resolve: { - preserveSymlinks: true, // we this for the build to work with workspaces, not 100% why + preserveSymlinks: true, // we need this for the build to work with workspaces, not 100% why }, plugins: [ reactRefresh(),