Commit d84cb3e
fix(client): use type-only imports for @modelcontextprotocol/sdk types (#157)
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>1 parent b9db70e commit d84cb3e
File tree
4 files changed
+4
-4
lines changed- sdks/typescript/client/src
- components
- __tests__
- utils
4 files changed
+4
-4
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments