From ff9b7a46d62f8975320756768ceb3ded5953b4ec Mon Sep 17 00:00:00 2001 From: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:26:47 -0700 Subject: [PATCH] chore: improve build process --- apps/cli/package.json | 2 -- package.json | 2 +- packages/tm-core/package.json | 2 -- packages/tm-core/tsup.config.ts | 41 --------------------------------- tsconfig.json | 10 +++++++- tsup.config.ts | 19 ++++++++++++++- turbo.json | 3 +-- 7 files changed, 29 insertions(+), 50 deletions(-) delete mode 100644 packages/tm-core/tsup.config.ts diff --git a/apps/cli/package.json b/apps/cli/package.json index 3e030acf..6252fc20 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -13,8 +13,6 @@ }, "files": ["dist", "README.md"], "scripts": { - "build": "tsc", - "dev": "tsc --watch", "typecheck": "tsc --noEmit", "lint": "biome check src", "format": "biome format --write src", diff --git a/package.json b/package.json index 597e0968..42e760aa 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "workspaces": ["apps/*", "packages/*", "."], "scripts": { "build": "npm run build:build-config && tsup", - "dev": "tsup --watch", + "dev": "tsup --watch='packages/*/src/**/*' --watch='apps/cli/src/**/*' --watch='bin/**/*' --watch='mcp-server/**/*'", "turbo:dev": "turbo dev", "turbo:build": "turbo build", "turbo:typecheck": "turbo typecheck", diff --git a/packages/tm-core/package.json b/packages/tm-core/package.json index 85a62665..e16a83de 100644 --- a/packages/tm-core/package.json +++ b/packages/tm-core/package.json @@ -53,8 +53,6 @@ } }, "scripts": { - "build": "tsup", - "dev": "tsup --watch", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", diff --git a/packages/tm-core/tsup.config.ts b/packages/tm-core/tsup.config.ts deleted file mode 100644 index e01e7a84..00000000 --- a/packages/tm-core/tsup.config.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { defineConfig } from 'tsup'; -import { baseConfig, mergeConfig } from '@tm/build-config'; -import { load as dotenvLoad } from 'dotenv-mono'; - -dotenvLoad(); - -// Get all TM_PUBLIC_* env variables for build-time injection -const getBuildTimeEnvs = () => { - const envs: Record = {}; - for (const [key, value] of Object.entries(process.env)) { - if (key.startsWith('TM_PUBLIC_')) { - // Return the actual value, not JSON.stringify'd - envs[key] = value || ''; - } - } - return envs; -}; - -export default defineConfig( - mergeConfig(baseConfig, { - entry: { - index: 'src/index.ts', - 'auth/index': 'src/auth/index.ts', - 'config/index': 'src/config/index.ts', - 'errors/index': 'src/errors/index.ts', - 'interfaces/index': 'src/interfaces/index.ts', - 'logger/index': 'src/logger/index.ts', - 'parser/index': 'src/parser/index.ts', - 'providers/index': 'src/providers/index.ts', - 'services/index': 'src/services/index.ts', - 'storage/index': 'src/storage/index.ts', - 'types/index': 'src/types/index.ts', - 'utils/index': 'src/utils/index.ts' - }, - format: ['esm'], - dts: true, - outDir: 'dist', - // Replace process.env.TM_PUBLIC_* with actual values at build time - env: getBuildTimeEnvs() - }) -); diff --git a/tsconfig.json b/tsconfig.json index d6057af0..58a2d25b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,15 @@ "strict": true, "skipLibCheck": true, "noEmit": true, - "baseUrl": "." + "baseUrl": ".", + "paths": { + "@tm/core": ["./packages/tm-core/src/index.ts"], + "@tm/core/*": ["./packages/tm-core/src/*"], + "@tm/cli": ["./apps/cli/src/index.ts"], + "@tm/cli/*": ["./apps/cli/src/*"], + "@tm/build-config": ["./packages/build-config/src/index.ts"], + "@tm/build-config/*": ["./packages/build-config/src/*"] + } }, "tsx": { "tsconfig": { diff --git a/tsup.config.ts b/tsup.config.ts index 3f301d71..41f9dd14 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,5 +1,21 @@ import { defineConfig } from 'tsup'; import { baseConfig, mergeConfig } from '@tm/build-config'; +import { load as dotenvLoad } from 'dotenv-mono'; + +dotenvLoad(); + +// Get all TM_PUBLIC_* env variables for build-time injection +const getBuildTimeEnvs = () => { + const envs: Record = {}; + for (const [key, value] of Object.entries(process.env)) { + if (key.startsWith('TM_PUBLIC_')) { + // Return the actual value, not JSON.stringify'd + envs[key] = value || ''; + } + } + return envs; +}; + export default defineConfig( mergeConfig(baseConfig, { @@ -21,6 +37,7 @@ export default defineConfig( 'tests', '*.test.*', '*.spec.*' - ] + ], + env: getBuildTimeEnvs() }) ); diff --git a/turbo.json b/turbo.json index 4ac183fd..54bb815c 100644 --- a/turbo.json +++ b/turbo.json @@ -10,7 +10,6 @@ "dev": { "cache": false, "persistent": true, - "dependsOn": ["^build"], "inputs": [ "$TURBO_DEFAULT$", "!{packages,apps}/**/dist/**", @@ -42,4 +41,4 @@ } }, "globalDependencies": ["turbo.json", "tsconfig.json", ".env*"] -} +} \ No newline at end of file