diff --git a/packages/middleware/express/tsdown.config.ts b/packages/middleware/express/tsdown.config.ts index 64ed143a86..c67ee585cd 100644 --- a/packages/middleware/express/tsdown.config.ts +++ b/packages/middleware/express/tsdown.config.ts @@ -12,11 +12,11 @@ export default defineConfig({ shims: true, dts: { resolver: 'tsc', + // Keep workspace deps as external imports in the bundled .d.ts instead of + // inlining their type graph — see ../node/tsdown.config.ts for the rationale. compilerOptions: { - baseUrl: '.', - paths: { - '@modelcontextprotocol/server': ['../server/src/index.ts'] - } + paths: {}, + preserveSymlinks: true } } }); diff --git a/packages/middleware/fastify/tsdown.config.ts b/packages/middleware/fastify/tsdown.config.ts index 64ed143a86..c67ee585cd 100644 --- a/packages/middleware/fastify/tsdown.config.ts +++ b/packages/middleware/fastify/tsdown.config.ts @@ -12,11 +12,11 @@ export default defineConfig({ shims: true, dts: { resolver: 'tsc', + // Keep workspace deps as external imports in the bundled .d.ts instead of + // inlining their type graph — see ../node/tsdown.config.ts for the rationale. compilerOptions: { - baseUrl: '.', - paths: { - '@modelcontextprotocol/server': ['../server/src/index.ts'] - } + paths: {}, + preserveSymlinks: true } } }); diff --git a/packages/middleware/hono/tsdown.config.ts b/packages/middleware/hono/tsdown.config.ts index 64ed143a86..c67ee585cd 100644 --- a/packages/middleware/hono/tsdown.config.ts +++ b/packages/middleware/hono/tsdown.config.ts @@ -12,11 +12,11 @@ export default defineConfig({ shims: true, dts: { resolver: 'tsc', + // Keep workspace deps as external imports in the bundled .d.ts instead of + // inlining their type graph — see ../node/tsdown.config.ts for the rationale. compilerOptions: { - baseUrl: '.', - paths: { - '@modelcontextprotocol/server': ['../server/src/index.ts'] - } + paths: {}, + preserveSymlinks: true } } }); diff --git a/packages/middleware/node/src/streamableHttp.ts b/packages/middleware/node/src/streamableHttp.ts index 68a0c224f0..c101fcd0af 100644 --- a/packages/middleware/node/src/streamableHttp.ts +++ b/packages/middleware/node/src/streamableHttp.ts @@ -10,8 +10,14 @@ import type { IncomingMessage, ServerResponse } from 'node:http'; import { getRequestListener } from '@hono/node-server'; -import type { AuthInfo, JSONRPCMessage, MessageExtraInfo, RequestId, Transport } from '@modelcontextprotocol/core'; -import type { WebStandardStreamableHTTPServerTransportOptions } from '@modelcontextprotocol/server'; +import type { + AuthInfo, + JSONRPCMessage, + MessageExtraInfo, + RequestId, + Transport, + WebStandardStreamableHTTPServerTransportOptions +} from '@modelcontextprotocol/server'; import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/server'; /** diff --git a/packages/middleware/node/tsdown.config.ts b/packages/middleware/node/tsdown.config.ts index 7d90f6517f..f953bc65de 100644 --- a/packages/middleware/node/tsdown.config.ts +++ b/packages/middleware/node/tsdown.config.ts @@ -21,12 +21,23 @@ export default defineConfig({ // Bundles d.ts files into a single output dts: { resolver: 'tsc', - // override just for DTS generation: + // The dev tsconfig.json maps @modelcontextprotocol/* to workspace source via + // `paths` so typecheck/IDE work without a prior build. For declaration emit we + // need the opposite: resolve workspace deps through node_modules and keep them + // as *external* imports in the bundled .d.ts (server is a peerDependency, so + // consumers already have its types). `paths: {}` disables the dev source + // mappings; `preserveSymlinks` keeps `node_modules` in the resolved path so + // rolldown-plugin-dts recognises the dep as external instead of inlining the + // whole upstream type graph (which OOMs once core's surface gets large enough). + // + // TODO: drop this override once tsdown pulls rolldown-plugin-dts >=0.21.0 + // (sxzz/rolldown-plugin-dts@03998d41 honours rolldown `external` before the + // node_modules path test). Bumping also requires reworking the `dts.resolve` + // usage in packages/{server,client}/tsdown.config.ts — that option was removed + // in the same release. compilerOptions: { - baseUrl: '.', - paths: { - '@modelcontextprotocol/core': ['../core/src/index.ts'] - } + paths: {}, + preserveSymlinks: true } } });