Skip to content

Conversation

@RazvanRotaru
Copy link

Change value imports to import type syntax for SDK types to prevent bundlers from including Node.js server code in browser builds.

When bundling @mcp-ui/client for pure browser environments, the @modelcontextprotocol/sdk's server-side code (which imports Express) was being included due to the import chain, causing "require is not defined" errors at runtime.

Since the SDK is only used for TypeScript types (not runtime values), using import type ensures these imports are stripped at compile time and don't trigger bundling of the SDK's server-side modules.

Files changed:

  • UIResourceRendererWC.tsx: EmbeddedResource type
  • metadataUtils.ts: Resource type
  • processResource.ts: EmbeddedResource, Resource types
  • UIResourceRenderer.unmocked.test.tsx: EmbeddedResource type

🤖 Generated with Claude Code

Change value imports to `import type` syntax for SDK types to prevent
bundlers from including Node.js server code in browser builds.

When bundling @mcp-ui/client for pure browser environments, the
@modelcontextprotocol/sdk's server-side code (which imports Express)
was being included due to the import chain, causing "require is not
defined" errors at runtime.

Since the SDK is only used for TypeScript types (not runtime values),
using `import type` ensures these imports are stripped at compile time
and don't trigger bundling of the SDK's server-side modules.

Files changed:
- UIResourceRendererWC.tsx: EmbeddedResource type
- metadataUtils.ts: Resource type
- processResource.ts: EmbeddedResource, Resource types
- UIResourceRenderer.unmocked.test.tsx: EmbeddedResource type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant