fix(middleware): stop bundling workspace type graphs into .d.ts (avoids dts-gen OOM) (#2339)
This commit is contained in:
parent
5e0249f57f
commit
6312f2a3ec
5 changed files with 36 additions and 19 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue