Configure TypeScript project references
Improvements:
- The common/ project is automatically built by dependent projects
- Building common/ in in the "prepare" script is thus no longer necessary
- Vite and server hot-reloading now work if files in common/ change
- Recompiling common after every change is done automatically
- Using "go to definition" now jumps to the .ts file rather than the .d.ts
Changes:
- Use TypeScript project references to refer to common/ from client/ and server/
- Set "composite" and "declarationMap" options in common/tsconfig.json
- See https://www.typescriptlang.org/docs/handbook/project-references.html
- Use tsc --build in order to build references automatically
- Replace nodemon and ts-node with ts-watch in server in order to use the new tsc --build mode
- See https://github.com/TypeStrong/ts-node/issues/897#issuecomment-647035509
- Remove now unneeded SIGUSR2 signal handler which was for nodemon
- Use tsc-watch before Vite in client in order for hot-reloading to work if common/ changes
- Update TypeScript version
- Add vite.config.node.json to be consistent with expected Vite project defaults
GitLab: #151
Change-Id: Id2f84fe45e44c4d8b4e6d3b324e1aee322c52df6
diff --git a/package.json b/package.json
index de8f59e..b7128a2 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"lint:fix": "npm run lint:fix --workspaces",
"format": "npm run format --workspaces",
"format:check": "npm run format:check --workspaces",
- "prepare": "([ -e '.git' ] && git config core.hooksPath .hooks); npm run build --workspace common"
+ "prepare": "if [ -e '.git' ]; then git config core.hooksPath .hooks; fi"
},
"lint-staged": {
"**/*.{ts,tsx,js,jsx,cjs,html}": [
@@ -28,8 +28,8 @@
]
},
"devDependencies": {
- "@typescript-eslint/eslint-plugin": "^5.37.0",
- "@typescript-eslint/parser": "^5.37.0",
+ "@typescript-eslint/eslint-plugin": "^5.43.0",
+ "@typescript-eslint/parser": "^5.43.0",
"concurrently": "^7.4.0",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",