fix(middleware): stop bundling workspace type graphs into .d.ts (avoids dts-gen OOM) (#2339)

This commit is contained in:
Felix Weinberger 2026-06-23 10:26:49 +01:00 • committed by GitHub
commit 6312f2a3ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 19 deletions

View file

@ -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
}
}
});

View file

@ -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
}
}
});

View file

@ -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
}
}
});

View file

@ -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';
/**

View file

@ -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
}
}
});