Skip to content

Commit 7bd609c

Browse files
committed
add tsdown
1 parent 7e92ba4 commit 7bd609c

File tree

12 files changed

+525
-48
lines changed

12 files changed

+525
-48
lines changed

common/eslint-config/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default tseslint.config(
5555
'**/*.test.tsx',
5656
'**/scripts/**',
5757
'**/vitest.config.*',
58+
'**/tsdown.config.*',
5859
'**/eslint.config.*',
5960
'**/vitest.setup.*'
6061
],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"eslint-plugin-n": "catalog:devTools",
4949
"prettier": "catalog:devTools",
5050
"supertest": "catalog:devTools",
51+
"tsdown": "catalog:devTools",
5152
"tsx": "catalog:devTools",
5253
"typescript": "catalog:devTools",
5354
"typescript-eslint": "catalog:devTools",

packages/client/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
],
3232
"scripts": {
3333
"typecheck": "tsc -p tsconfig.build.json --noEmit",
34-
"build": "npm run build:esm",
35-
"build:esm": "mkdir -p dist && echo '{\"type\": \"module\"}' > dist/package.json && tsc -p tsconfig.build.json",
36-
"build:esm:w": "npm run build:esm -- -w",
37-
"prepack": "npm run build:esm",
34+
"build": "tsdown",
35+
"build:watch": "tsdown --watch",
36+
"prepack": "npm run build",
3837
"lint": "eslint src/ && prettier --check .",
3938
"lint:fix": "eslint src/ --fix && prettier --write .",
4039
"check": "npm run typecheck && npm run lint",
@@ -45,7 +44,6 @@
4544
"client": "tsx scripts/cli.ts client"
4645
},
4746
"dependencies": {
48-
"@modelcontextprotocol/sdk-core": "workspace:^",
4947
"cross-spawn": "catalog:runtimeClientOnly",
5048
"eventsource": "catalog:runtimeClientOnly",
5149
"eventsource-parser": "catalog:runtimeClientOnly",
@@ -66,6 +64,7 @@
6664
}
6765
},
6866
"devDependencies": {
67+
"@modelcontextprotocol/sdk-core": "workspace:^",
6968
"@modelcontextprotocol/tsconfig": "workspace:^",
7069
"@modelcontextprotocol/vitest-config": "workspace:^",
7170
"@modelcontextprotocol/eslint-config": "workspace:^",
@@ -80,6 +79,7 @@
8079
"eslint-config-prettier": "catalog:devTools",
8180
"eslint-plugin-n": "catalog:devTools",
8281
"prettier": "catalog:devTools",
82+
"tsdown": "catalog:devTools",
8383
"tsx": "catalog:devTools",
8484
"typescript": "catalog:devTools",
8585
"typescript-eslint": "catalog:devTools",

packages/client/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"baseUrl": ".",
77
"paths": {
88
"*": ["./*"],
9-
"@modelcontextprotocol/sdk-core": ["node_modules/@modelcontextprotocol/sdk-core/src/index.ts"],
9+
"@modelcontextprotocol/sdk-core": ["../core/src/index.ts"],
1010
"@modelcontextprotocol/sdk-client": ["node_modules/@modelcontextprotocol/sdk-client/src/index.ts"],
1111
"@modelcontextprotocol/vitest-config": ["node_modules/@modelcontextprotocol/vitest-config/tsconfig.json"],
1212
"@modelcontextprotocol/eslint-config": ["node_modules/@modelcontextprotocol/eslint-config/tsconfig.json"]

packages/client/tsdown.config.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineConfig } from 'tsdown';
2+
3+
export default defineConfig({
4+
// 1. Entry Points
5+
// Directly matches package.json include/exclude globs
6+
entry: [
7+
'src/**/*.ts',
8+
'!src/**/*.test.ts',
9+
'!src/__mocks__/**',
10+
'!src/examples/**'
11+
],
12+
13+
// 2. Output Configuration
14+
format: ['esm'],
15+
outDir: 'dist',
16+
clean: true, // Recommended: Cleans 'dist' before building
17+
sourcemap: true,
18+
19+
// 3. Platform & Target
20+
target: 'esnext',
21+
platform: 'node',
22+
shims: true, // Polyfills common Node.js shims (__dirname, etc.)
23+
24+
// 4. Type Definitions
25+
// Bundles d.ts files into a single output
26+
dts: true,
27+
28+
// 5. Vendoring Strategy - Bundle the code for this specific package into the output,
29+
// but treat all other dependencies as external (require/import).
30+
noExternal: ['@modelcontextprotocol/sdk-core']
31+
});

packages/core/package.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,6 @@
2121
"modelcontextprotocol",
2222
"mcp"
2323
],
24-
"exports": {
25-
".": {
26-
"import": "./dist/index.js",
27-
"types": "./dist/index.d.ts"
28-
},
29-
"./types": {
30-
"import": "./dist/exports/types/index.js",
31-
"types": "./dist/exports/types/index.d.ts"
32-
}
33-
},
34-
"files": [
35-
"dist"
36-
],
3724
"scripts": {
3825
"fetch:spec-types": "tsx scripts/fetch-spec-types.ts",
3926
"typecheck": "tsc -p tsconfig.build.json --noEmit",

packages/integration/package.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,6 @@
2121
"modelcontextprotocol",
2222
"mcp"
2323
],
24-
"exports": {
25-
".": {
26-
"import": "./dist/index.js",
27-
"types": "./dist/index.d.ts"
28-
},
29-
"./types": {
30-
"import": "./dist/exports/types/index.js",
31-
"types": "./dist/exports/types/index.d.ts"
32-
}
33-
},
34-
"files": [
35-
"dist"
36-
],
3724
"scripts": {
3825
"fetch:spec-types": "tsx scripts/fetch-spec-types.ts",
3926
"lint": "eslint test/ && prettier --check .",

packages/server/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232
"scripts": {
3333
"fetch:spec-types": "tsx scripts/fetch-spec-types.ts",
3434
"typecheck": "tsc -p tsconfig.build.json --noEmit",
35-
"build": "npm run build:esm",
36-
"build:esm": "mkdir -p dist && echo '{\"type\": \"module\"}' > dist/package.json && tsc -p tsconfig.build.json",
37-
"build:esm:w": "npm run build:esm -- -w",
38-
"prepack": "npm run build:esm",
35+
"build": "tsdown",
36+
"build:watch": "tsdown --watch",
37+
"prepack": "npm run build",
3938
"lint": "eslint src/ && prettier --check .",
4039
"lint:fix": "eslint src/ --fix && prettier --write .",
4140
"check": "npm run typecheck && npm run lint",
@@ -46,7 +45,6 @@
4645
"client": "tsx scripts/cli.ts client"
4746
},
4847
"dependencies": {
49-
"@modelcontextprotocol/sdk-core": "workspace:^",
5048
"content-type": "catalog:runtimeServerOnly",
5149
"cors": "catalog:runtimeServerOnly",
5250
"express": "catalog:runtimeServerOnly",
@@ -69,6 +67,7 @@
6967
}
7068
},
7169
"devDependencies": {
70+
"@modelcontextprotocol/sdk-core": "workspace:^",
7271
"@modelcontextprotocol/tsconfig": "workspace:^",
7372
"@modelcontextprotocol/vitest-config": "workspace:^",
7473
"@modelcontextprotocol/eslint-config": "workspace:^",
@@ -87,6 +86,7 @@
8786
"eslint-plugin-n": "catalog:devTools",
8887
"prettier": "catalog:devTools",
8988
"supertest": "catalog:devTools",
89+
"tsdown": "catalog:devTools",
9090
"tsx": "catalog:devTools",
9191
"typescript": "catalog:devTools",
9292
"typescript-eslint": "catalog:devTools",

packages/server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"baseUrl": ".",
77
"paths": {
88
"*": ["./*"],
9-
"@modelcontextprotocol/sdk-core": ["node_modules/@modelcontextprotocol/sdk-core/src/index.ts"]
9+
"@modelcontextprotocol/sdk-core": ["../core/src/index.ts"]
1010
}
1111
}
1212
}

packages/server/tsdown.config.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineConfig } from 'tsdown';
2+
3+
export default defineConfig({
4+
// 1. Entry Points
5+
// Directly matches package.json include/exclude globs
6+
entry: [
7+
'src/**/*.ts',
8+
'!src/**/*.test.ts',
9+
'!src/__mocks__/**',
10+
'!src/examples/**'
11+
],
12+
13+
// 2. Output Configuration
14+
format: ['esm'],
15+
outDir: 'dist',
16+
clean: true, // Recommended: Cleans 'dist' before building
17+
sourcemap: true,
18+
19+
// 3. Platform & Target
20+
target: 'esnext',
21+
platform: 'node',
22+
shims: true, // Polyfills common Node.js shims (__dirname, etc.)
23+
24+
// 4. Type Definitions
25+
// Bundles d.ts files into a single output
26+
dts: true,
27+
28+
// 5. CRITICAL: Vendoring Strategy
29+
// This tells tsdown: "Bundle the code for this specific package into the output,
30+
// but treat all other dependencies as external (require/import)."
31+
noExternal: [
32+
'@modelcontextprotocol/sdk-core'
33+
]
34+
});

0 commit comments

Comments
 (0)