Skip to content

Commit d26eeb1

Browse files
committed
fix(build): use --external for Windows bun compatibility
Bun on Windows incorrectly treats imported .ts files as entry points. Use --external './server.js' to work around this, creating a runtime dependency between index.js and server.js.
1 parent aa343c6 commit d26eeb1

38 files changed

Lines changed: 38 additions & 38 deletions

File tree

examples/basic-server-preact/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1414
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1515
import cors from "cors";
1616
import type { Request, Response } from "express";
17-
import { createServer } from "./server.ts";
17+
import { createServer } from "./server.js";
1818

1919
export interface ServerOptions {
2020
port: number;

examples/basic-server-preact/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --banner '#!/usr/bin/env node'",
17+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external './server.js' --banner '#!/usr/bin/env node'",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-react/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
1010
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1111
import cors from "cors";
1212
import type { Request, Response } from "express";
13-
import { createServer } from "./server.ts";
13+
import { createServer } from "./server.js";
1414

1515
export interface ServerOptions {
1616
port: number;

examples/basic-server-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525
},
2626
"scripts": {
27-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --banner '#!/usr/bin/env node'",
27+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external './server.js' --banner '#!/usr/bin/env node'",
2828
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
2929
"serve": "bun --watch main.ts",
3030
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-solid/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1414
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1515
import cors from "cors";
1616
import type { Request, Response } from "express";
17-
import { createServer } from "./server.ts";
17+
import { createServer } from "./server.js";
1818

1919
export interface ServerOptions {
2020
port: number;

examples/basic-server-solid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --banner '#!/usr/bin/env node'",
17+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external './server.js' --banner '#!/usr/bin/env node'",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-svelte/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1414
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1515
import cors from "cors";
1616
import type { Request, Response } from "express";
17-
import { createServer } from "./server.ts";
17+
import { createServer } from "./server.js";
1818

1919
export interface ServerOptions {
2020
port: number;

examples/basic-server-svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --banner '#!/usr/bin/env node'",
17+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external './server.js' --banner '#!/usr/bin/env node'",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

examples/basic-server-vanillajs/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1414
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1515
import cors from "cors";
1616
import type { Request, Response } from "express";
17-
import { createServer } from "./server.ts";
17+
import { createServer } from "./server.js";
1818

1919
export interface ServerOptions {
2020
port: number;

examples/basic-server-vanillajs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dist"
1515
],
1616
"scripts": {
17-
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --banner '#!/usr/bin/env node'",
17+
"build": "tsc --noEmit && cross-env INPUT=mcp-app.html vite build && tsc -p tsconfig.server.json && bun build server.ts --outdir dist --target node && bun build main.ts --outfile dist/index.js --target node --external './server.js' --banner '#!/usr/bin/env node'",
1818
"watch": "cross-env INPUT=mcp-app.html vite build --watch",
1919
"serve": "bun --watch main.ts",
2020
"start": "cross-env NODE_ENV=development npm run build && npm run serve",

0 commit comments

Comments
 (0)