collab/mcp: bundle workspace deps so runtime doesn't import .ts files
@tasks/database (and @tasks/shared) export raw .ts files via "main" / "exports", which works fine for tsx/dev but blows up at runtime in the production image: ERR_UNKNOWN_FILE_EXTENSION: Unknown file extension ".ts" for /app/packages/database/src/client.ts tsup was leaving those workspace imports as externals in the output, so the deployed dist/index.mjs still tried to resolve them at startup. Switch each app to a tsup.config.ts that sets noExternal: [/^@tasks\\//], which inlines workspace packages into the bundle while keeping node_modules deps (postgres, drizzle-orm, hocuspocus, mcp-sdk, etc.) external. Verified locally: collab-server bundle size goes from 7 KB to 304 KB, confirming @tasks/database is now compiled in. Also fixed the collab start script to point at index.mjs (tsup ESM output) instead of .js. Made-with: Cursor
This commit is contained in:
parent
403437dafc
commit
829cbdc899
4 changed files with 33 additions and 3 deletions
|
|
@ -4,8 +4,8 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx watch src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"build": "tsup src/index.ts --format esm --dts",
|
"build": "tsup",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.mjs",
|
||||||
"type-check": "tsc --noEmit"
|
"type-check": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
15
apps/collab-server/tsup.config.ts
Normal file
15
apps/collab-server/tsup.config.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { defineConfig } from "tsup";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ["src/index.ts"],
|
||||||
|
format: ["esm"],
|
||||||
|
dts: true,
|
||||||
|
// Bundle workspace packages into the output so the runtime image doesn't try
|
||||||
|
// to resolve `@tasks/database` (which exports raw .ts files) at import time —
|
||||||
|
// Node 20 cannot load .ts. Third-party deps stay external and are installed
|
||||||
|
// via the regular node_modules layer in the runtime image.
|
||||||
|
noExternal: [/^@tasks\//],
|
||||||
|
target: "node20",
|
||||||
|
platform: "node",
|
||||||
|
clean: true,
|
||||||
|
});
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx watch src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"build": "tsup src/index.ts --format esm --dts",
|
"build": "tsup",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"type-check": "tsc --noEmit"
|
"type-check": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
15
apps/mcp-server/tsup.config.ts
Normal file
15
apps/mcp-server/tsup.config.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { defineConfig } from "tsup";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ["src/index.ts"],
|
||||||
|
format: ["esm"],
|
||||||
|
dts: true,
|
||||||
|
// Bundle workspace packages into the output so the runtime image doesn't try
|
||||||
|
// to resolve `@tasks/database` / `@tasks/shared` (which export raw .ts files)
|
||||||
|
// at import time — Node 20 cannot load .ts. Third-party deps stay external
|
||||||
|
// and are installed via the regular node_modules layer in the runtime image.
|
||||||
|
noExternal: [/^@tasks\//],
|
||||||
|
target: "node20",
|
||||||
|
platform: "node",
|
||||||
|
clean: true,
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue