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/client/package.json b/client/package.json
index e8e26f0..3620108 100644
--- a/client/package.json
+++ b/client/package.json
@@ -4,10 +4,10 @@
"private": true,
"type": "module",
"scripts": {
- "start": "vite",
+ "start": "tsc-watch --build ../common --onSuccess \"vite\"",
"start:prod": "vite preview",
- "build": "tsc && vite build",
- "clean": "rm -rf dist",
+ "build": "tsc --build && vite build",
+ "clean": "rm -rf dist *.tsbuildinfo",
"test": "jest src",
"test:cypress": "cypress open",
"lint": "eslint .",
@@ -48,7 +48,6 @@
"filesize": "^10.0.5",
"framer-motion": "^7.3.5",
"i18next": "^21.9.2",
- "jami-web-common": "file:../common",
"mime": "^3.0.0",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
@@ -64,6 +63,7 @@
},
"devDependencies": {
"@types/jest": "^28.1.8",
+ "@types/node": "^18.11.9",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/react-modal": "^3.13.1",
@@ -73,8 +73,9 @@
"eslint-plugin-react-hooks": "^4.6.0",
"i18next-parser": "^6.5.0",
"sass": "^1.54.5",
- "typescript": "^4.7.4",
- "vite": "^3.1.8",
+ "tsc-watch": "^5.0.3",
+ "typescript": "~4.8.4",
+ "vite": "^3.2.3",
"vite-plugin-svgr": "^2.2.2"
}
}