From 4acb2e67f81e66af66fe9c613016f6d62423a7c6 Mon Sep 17 00:00:00 2001 From: yctimlin Date: Sat, 12 Jul 2025 05:18:01 +0000 Subject: [PATCH] Enhance build process and add TypeScript configuration - Update package.json to include separate build scripts for frontend and types, and add a build server script. - Introduce tsconfig.json for TypeScript configuration, enabling declaration files and source maps. - Add TypeScript and Node types as development dependencies. - Include TypeScript declaration files in the package distribution. --- package.json | 8 +++++++- tsconfig.json | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tsconfig.json diff --git a/package.json b/package.json index a7cf20a..2e10f8e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,10 @@ "scripts": { "start": "node src/index.js", "canvas": "node src/server.js", - "build": "vite build", + "build": "npm run build:frontend && npm run build:types", + "build:frontend": "vite build", + "build:types": "npx tsc --emitDeclarationOnly", + "build:server": "npx tsc", "dev": "concurrently \"npm run canvas\" \"vite\"", "production": "npm run build && npm run canvas", "prepublishOnly": "npm run build" @@ -30,8 +33,10 @@ "zod-to-json-schema": "^3.22.3" }, "devDependencies": { + "@types/node": "^20.19.7", "@vitejs/plugin-react": "^4.6.0", "concurrently": "^9.2.0", + "typescript": "^5.8.3", "vite": "^6.3.5" }, "keywords": [ @@ -72,6 +77,7 @@ "files": [ "src/**/*", "dist/**/*", + "*.d.ts", "README.md", "LICENSE" ] diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..7bcf949 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,38 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "node", + "allowJs": true, + "checkJs": false, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./dist", + "rootDir": "./src", + "strict": false, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmitOnError": false, + "preserveConstEnums": true, + "removeComments": false, + "types": ["node"] + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules", + "dist", + "frontend", + "**/*.test.js", + "**/*.spec.js" + ], + "ts-node": { + "esm": true + } +} \ No newline at end of file