Skip to content

Commit 6312f2a

Browse files
fix(middleware): stop bundling workspace type graphs into .d.ts (avoids dts-gen OOM) (#2339)
1 parent 5e0249f commit 6312f2a

5 files changed

Lines changed: 36 additions & 19 deletions

File tree

packages/middleware/express/tsdown.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export default defineConfig({
1212
shims: true,
1313
dts: {
1414
resolver: 'tsc',
15+
// Keep workspace deps as external imports in the bundled .d.ts instead of
16+
// inlining their type graph — see ../node/tsdown.config.ts for the rationale.
1517
compilerOptions: {
16-
baseUrl: '.',
17-
paths: {
18-
'@modelcontextprotocol/server': ['../server/src/index.ts']
19-
}
18+
paths: {},
19+
preserveSymlinks: true
2020
}
2121
}
2222
});

packages/middleware/fastify/tsdown.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export default defineConfig({
1212
shims: true,
1313
dts: {
1414
resolver: 'tsc',
15+
// Keep workspace deps as external imports in the bundled .d.ts instead of
16+
// inlining their type graph — see ../node/tsdown.config.ts for the rationale.
1517
compilerOptions: {
16-
baseUrl: '.',
17-
paths: {
18-
'@modelcontextprotocol/server': ['../server/src/index.ts']
19-
}
18+
paths: {},
19+
preserveSymlinks: true
2020
}
2121
}
2222
});

packages/middleware/hono/tsdown.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export default defineConfig({
1212
shims: true,
1313
dts: {
1414
resolver: 'tsc',
15+
// Keep workspace deps as external imports in the bundled .d.ts instead of
16+
// inlining their type graph — see ../node/tsdown.config.ts for the rationale.
1517
compilerOptions: {
16-
baseUrl: '.',
17-
paths: {
18-
'@modelcontextprotocol/server': ['../server/src/index.ts']
19-
}
18+
paths: {},
19+
preserveSymlinks: true
2020
}
2121
}
2222
});

packages/middleware/node/src/streamableHttp.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
import type { IncomingMessage, ServerResponse } from 'node:http';
1111

1212
import { getRequestListener } from '@hono/node-server';
13-
import type { AuthInfo, JSONRPCMessage, MessageExtraInfo, RequestId, Transport } from '@modelcontextprotocol/core';
14-
import type { WebStandardStreamableHTTPServerTransportOptions } from '@modelcontextprotocol/server';
13+
import type {
14+
AuthInfo,
15+
JSONRPCMessage,
16+
MessageExtraInfo,
17+
RequestId,
18+
Transport,
19+
WebStandardStreamableHTTPServerTransportOptions
20+
} from '@modelcontextprotocol/server';
1521
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/server';
1622

1723
/**

packages/middleware/node/tsdown.config.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@ export default defineConfig({
2121
// Bundles d.ts files into a single output
2222
dts: {
2323
resolver: 'tsc',
24-
// override just for DTS generation:
24+
// The dev tsconfig.json maps @modelcontextprotocol/* to workspace source via
25+
// `paths` so typecheck/IDE work without a prior build. For declaration emit we
26+
// need the opposite: resolve workspace deps through node_modules and keep them
27+
// as *external* imports in the bundled .d.ts (server is a peerDependency, so
28+
// consumers already have its types). `paths: {}` disables the dev source
29+
// mappings; `preserveSymlinks` keeps `node_modules` in the resolved path so
30+
// rolldown-plugin-dts recognises the dep as external instead of inlining the
31+
// whole upstream type graph (which OOMs once core's surface gets large enough).
32+
//
33+
// TODO: drop this override once tsdown pulls rolldown-plugin-dts >=0.21.0
34+
// (sxzz/rolldown-plugin-dts@03998d41 honours rolldown `external` before the
35+
// node_modules path test). Bumping also requires reworking the `dts.resolve`
36+
// usage in packages/{server,client}/tsdown.config.ts — that option was removed
37+
// in the same release.
2538
compilerOptions: {
26-
baseUrl: '.',
27-
paths: {
28-
'@modelcontextprotocol/core': ['../core/src/index.ts']
29-
}
39+
paths: {},
40+
preserveSymlinks: true
3041
}
3142
}
3243
});

0 commit comments

Comments
 (0)