Skip to content

Commit ee732d6

Browse files
authored
chore: switch to module ESNext + moduleResolution bundler (#2095)
1 parent c59dc3a commit ee732d6

235 files changed

Lines changed: 668 additions & 863 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Include what changed, why, and how to migrate. Search for related sections and g
3636
- **TypeScript**: Strict type checking, ES modules, explicit return types
3737
- **Naming**: PascalCase for classes/types, camelCase for functions/variables
3838
- **Files**: Lowercase with hyphens, test files with `.test.ts` suffix
39-
- **Imports**: ES module style, include `.js` extension, group imports logically
39+
- **Imports**: ES module style, no `.js` extension on relative imports (project uses `moduleResolution: bundler`), group imports logically
4040
- **Formatting**: 2-space indentation, semicolons required, single quotes preferred
4141
- **Testing**: Place tests under each package's `test/` directory (vitest only includes `test/**/*.test.ts`), use descriptive test names
4242
- **Comments**: JSDoc for public APIs, inline comments for complex logic

common/eslint-config/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default defineConfig(
3636
settings: {
3737
'import/resolver': {
3838
typescript: {
39-
// Let the TS resolver handle NodeNext-style imports like "./foo.js"
39+
// Resolve extensionless relative imports (moduleResolution: bundler) to their TS sources
4040
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
4141
// Use the tsconfig in each package root (when running ESLint from that package)
4242
project: 'tsconfig.json'

common/tsconfig/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"compilerOptions": {
33
"target": "esnext",
44
"lib": ["esnext"],
5-
"module": "NodeNext",
6-
"moduleResolution": "NodeNext",
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
77
"noFallthroughCasesInSwitch": true,
88
"noUncheckedIndexedAccess": true,
99
"noImplicitOverride": true,

docs/client-quickstart.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ Create a `tsconfig.json` in the root of your project:
8888
```json
8989
{
9090
"compilerOptions": {
91-
"target": "ES2023",
92-
"lib": ["ES2023"],
93-
"module": "Node16",
94-
"moduleResolution": "Node16",
91+
"target": "ESNext",
92+
"lib": ["ESNext"],
93+
"module": "ESNext",
94+
"moduleResolution": "bundler",
9595
"outDir": "./build",
9696
"rootDir": "./src",
9797
"strict": true,
@@ -236,7 +236,8 @@ Now let's add the core functionality for processing queries and handling tool ca
236236
messages,
237237
});
238238

239-
finalText.push(followUp.content[0].type === 'text' ? followUp.content[0].text : '');
239+
const firstBlock = followUp.content[0];
240+
finalText.push(firstBlock?.type === 'text' ? firstBlock.text : '');
240241
}
241242
}
242243

@@ -284,13 +285,14 @@ Finally, we'll add the main execution logic:
284285

285286
```ts source="../examples/client-quickstart/src/index.ts#main"
286287
async function main() {
287-
if (process.argv.length < 3) {
288+
const serverScriptPath = process.argv[2];
289+
if (!serverScriptPath) {
288290
console.log('Usage: node build/index.js <path_to_server_script>');
289291
return;
290292
}
291293
const mcpClient = new MCPClient();
292294
try {
293-
await mcpClient.connectToServer(process.argv[2]);
295+
await mcpClient.connectToServer(serverScriptPath);
294296

295297
// Check if we have a valid API key to continue
296298
const apiKey = process.env.ANTHROPIC_API_KEY;

docs/server-quickstart.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ Create a `tsconfig.json` in the root of your project:
103103
```json
104104
{
105105
"compilerOptions": {
106-
"target": "ES2022",
107-
"module": "Node16",
108-
"moduleResolution": "Node16",
106+
"target": "ESNext",
107+
"lib": ["ESNext"],
108+
"module": "ESNext",
109+
"moduleResolution": "bundler",
109110
"outDir": "./build",
110111
"rootDir": "./src",
111112
"strict": true,

examples/client-quickstart/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@modelcontextprotocol/client": "workspace:^"
1616
},
1717
"devDependencies": {
18+
"@modelcontextprotocol/tsconfig": "workspace:^",
1819
"@types/node": "^24.10.1",
1920
"typescript": "catalog:devTools"
2021
}

examples/client-quickstart/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class MCPClient {
116116
messages,
117117
});
118118

119-
finalText.push(followUp.content[0].type === 'text' ? followUp.content[0].text : '');
119+
const firstBlock = followUp.content[0];
120+
finalText.push(firstBlock?.type === 'text' ? firstBlock.text : '');
120121
}
121122
}
122123

@@ -156,13 +157,14 @@ class MCPClient {
156157

157158
//#region main
158159
async function main() {
159-
if (process.argv.length < 3) {
160+
const serverScriptPath = process.argv[2];
161+
if (!serverScriptPath) {
160162
console.log('Usage: node build/index.js <path_to_server_script>');
161163
return;
162164
}
163165
const mcpClient = new MCPClient();
164166
try {
165-
await mcpClient.connectToServer(process.argv[2]);
167+
await mcpClient.connectToServer(serverScriptPath);
166168

167169
// Check if we have a valid API key to continue
168170
const apiKey = process.env.ANTHROPIC_API_KEY;

examples/client-quickstart/tsconfig.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
2+
"extends": "@modelcontextprotocol/tsconfig",
23
"compilerOptions": {
3-
"target": "ES2023",
4-
"lib": ["ES2023"],
5-
"module": "Node16",
6-
"moduleResolution": "Node16",
74
"outDir": "./build",
85
"rootDir": "./src",
9-
"strict": true,
10-
"esModuleInterop": true,
11-
"skipLibCheck": true,
12-
"forceConsistentCasingInFileNames": true,
6+
"declaration": false,
7+
"declarationMap": false,
8+
"types": ["node"],
139
"paths": {
1410
"@modelcontextprotocol/client": ["./node_modules/@modelcontextprotocol/client/src/index.ts"],
1511
"@modelcontextprotocol/client/stdio": ["./node_modules/@modelcontextprotocol/client/src/stdio.ts"],

examples/client/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
"prepack": "pnpm run build:esm && pnpm run build:cjs",
2727
"lint": "eslint src/ && prettier --ignore-path ../../.prettierignore --check .",
2828
"lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .",
29-
"check": "pnpm run typecheck && pnpm run lint",
30-
"start": "pnpm run server",
31-
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
32-
"client": "tsx scripts/cli.ts client"
29+
"check": "pnpm run typecheck && pnpm run lint"
3330
},
3431
"dependencies": {
3532
"@modelcontextprotocol/client": "workspace:^",

examples/client/src/elicitationUrlExample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from '@modelcontextprotocol/client';
2828
import open from 'open';
2929

30-
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider.js';
30+
import { InMemoryOAuthClientProvider } from './simpleOAuthClientProvider';
3131

3232
// Set up OAuth (required for this example)
3333
const OAUTH_CALLBACK_PORT = 8090; // Use different port than auth server (3001)

0 commit comments

Comments
 (0)