From 0644783cc42064ea0568ceabd83778f8757d81cc Mon Sep 17 00:00:00 2001 From: wancat Date: Tue, 27 Feb 2024 12:27:54 +0800 Subject: [PATCH] feat: use project references to build dependencies efficiently --- app/tsconfig.json | 7 ++++++- package.json | 4 +--- packages/constants/tsconfig.json | 1 + packages/file-graph/tsconfig.json | 1 + packages/models/src/index.ts | 2 ++ packages/models/tsconfig.json | 1 + packages/utils/tsconfig.json | 1 + server/package.json | 4 ++-- server/tsconfig.json | 8 +++++++- tsconfig.json | 3 ++- 10 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/tsconfig.json b/app/tsconfig.json index b17c94a..dc7801a 100644 --- a/app/tsconfig.json +++ b/app/tsconfig.json @@ -22,5 +22,10 @@ "noFallthroughCasesInSwitch": true }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "src/**/*.js"], - "references": [{ "path": "./tsconfig.node.json" }] + "references": [ + { "path": "./tsconfig.node.json" }, + { "path": "../packages/utils" }, + { "path": "../packages/constants" }, + { "path": "../packages/file-graph" } + ] } diff --git a/package.json b/package.json index 04954b1..3888742 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,7 @@ ], "scripts": { "app": "yarn workspace app dev", - "build:deps": "concurrently \"yarn workspace @linux-odyssey/constants build\" \"yarn workspace @linux-odyssey/file-graph build\" \"yarn workspace @linux-odyssey/models build\" \"yarn workspace @linux-odyssey/utils build\"", - "build:apps": "concurrently \"yarn workspace app build\" \"yarn workspace server build\" \"yarn workspace analytics build\"", - "build": "yarn build:deps && yarn build:apps", + "build": "yarn workspace server build && yarn workspace app build && yarn workspace analytics build", "dev": "concurrently -n \"App,Server\" -c \"bgBlue.bold,bgGreen.bold\" \"yarn workspace app dev\" \"yarn workspace server dev\"", "server": "yarn workspace server dev", "cli": "yarn workspace client start", diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json index bd29af9..318a4cf 100644 --- a/packages/constants/tsconfig.json +++ b/packages/constants/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "composite": true, "outDir": "./dist" }, "include": ["*.js", "*.ts"], diff --git a/packages/file-graph/tsconfig.json b/packages/file-graph/tsconfig.json index bf649ac..ccaf320 100644 --- a/packages/file-graph/tsconfig.json +++ b/packages/file-graph/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "rootDir": "src", + "composite": true, "outDir": "./dist" }, "include": ["src"], diff --git a/packages/models/src/index.ts b/packages/models/src/index.ts index efdfd11..59332a0 100644 --- a/packages/models/src/index.ts +++ b/packages/models/src/index.ts @@ -15,3 +15,5 @@ export default async function connectDB(uri: string) { const db = await mongoose.connect(uri) return db.connection.getClient() } + +console.log('Loaded models package') diff --git a/packages/models/tsconfig.json b/packages/models/tsconfig.json index bf649ac..ccaf320 100644 --- a/packages/models/tsconfig.json +++ b/packages/models/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "rootDir": "src", + "composite": true, "outDir": "./dist" }, "include": ["src"], diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 8f50229..b1b8f57 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "rootDir": "src", "outDir": "./dist", + "composite": true, "allowJs": false }, "include": ["src"], diff --git a/server/package.json b/server/package.json index c6383ad..02b10c7 100644 --- a/server/package.json +++ b/server/package.json @@ -7,8 +7,8 @@ "start": "node dist/index.js", "setup": "node dist/cli/setup.js", "clean": "node dist/cli/clean.js", - "build": "tsc", - "dev": "concurrently \"tsc -w\" \"sleep 5 && nodemon\"", + "build": "tsc -b", + "dev": "concurrently \"tsc -b --watch\" \"sleep 5 && nodemon\"", "build:quests": "node dist/cli/build.js" }, "dependencies": { diff --git a/server/tsconfig.json b/server/tsconfig.json index efc3d54..321fdda 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -4,5 +4,11 @@ "outDir": "./dist" }, "include": ["src"], - "exclude": ["node_modules", "src/*.test.js", "dist"] + "exclude": ["node_modules", "src/*.test.js", "dist"], + "references": [ + { "path": "../packages/constants" }, + { "path": "../packages/file-graph" }, + { "path": "../packages/models" }, + { "path": "../packages/utils" } + ] } diff --git a/tsconfig.json b/tsconfig.json index 2cd1c93..862aad0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "strict": true, "skipLibCheck": true, "sourceMap": true, - "declaration": true + "declaration": true, + "declarationMap": true } }