Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hono のクライアントの補完を高速化 #19

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/scrap.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", ".wrangler", "drizzle", "*.gen.ts"]
"ignore": ["dist", ".wrangler", "drizzle", "*.gen.ts", "src/server/types"]
},
"formatter": {
"enabled": true,
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "scrap",
"type": "module",
"scripts": {
"dev": "vite dev",
"dev": "concurrently -r -k yarn:watch:server-types vite",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-r, --raw は余計な prefix などを付けない、-k, --kill-others はどれかが終了したら全て終了させる。

"build": "$npm_execpath run build:client && $npm_execpath run build:api",
"build:client": "vite build --mode client",
"build:api": "vite build",
Expand All @@ -11,7 +11,8 @@
"migrate": "drizzle-kit generate && wrangler d1 migrations apply scrap",
"migrate:remote": "drizzle-kit generate && wrangler d1 migrations apply scrap --remote ",
"lint": "biome check",
"lint:fix": "biome check --fix"
"lint:fix": "biome check --fix",
"watch:server-types": "tsc -b -w ./src/server"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ソースコードを更新したら再コンパイルが必要なので、tsc --watch で更新が必要です

},
"dependencies": {
"@hono/zod-validator": "^0.4.1",
Expand Down Expand Up @@ -52,10 +53,12 @@
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"autoprefixer": "^10.4.20",
"concurrently": "^9.1.0",
"drizzle-kit": "^0.26.2",
"postcss": "^8.4.47",
"postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1",
"typescript": "^5.6.3",
"vite": "^5.2.12",
"wrangler": "^3.57.2"
},
Expand Down
1 change: 1 addition & 0 deletions src/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
12 changes: 12 additions & 0 deletions src/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["../../tsconfig.base.json"],
"include": ["**/*", "../common/**/*", "../db/**/*", "../model/**/*"],
"compilerOptions": {
"composite": true,
"declaration": true,
Comment on lines +5 to +6
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./build/types",
"rootDir": "../"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

サーバーのコードが src/db など、親ディレクトリのものを参照するので必要です

}
}
18 changes: 18 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"types": ["@cloudflare/workers-types", "vite/client"],
"jsx": "react-jsx",
"jsxImportSource": "react",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"skipLibCheck": true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

依存パッケージで型エラーが起きたりするので、チェックを無効化

"noUncheckedIndexedAccess": true
}
}
23 changes: 9 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"extends": ["./tsconfig.base.json"],
"exclude": ["./src/server"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"types": ["@cloudflare/workers-types", "vite/client"],
"jsx": "react-jsx",
"jsxImportSource": "react",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"noUncheckedIndexedAccess": true
}
"disableSourceOfProjectReferenceRedirect": true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project reference とこのオプションを有効化すると、型情報はコンパイルした *.d.ts を参照するようになる。

詳しくは以下の PR のコメントを参照。

microsoft/TypeScript#32028 (comment)

},
"references": [
{
"path": "./src/server"
}
]
}
Loading