Skip to content

Commit 2b10490

Browse files
liadyclaude
andauthored
fix: emit CJS build so require('@mcp-ui/client') exposes exports (#211)
The require condition and main field pointed at dist/index.js, a UMD bundle. Because package.json has "type": "module", Node parses .js as ESM, so the UMD wrapper's exports check never fires and require() returns an empty object (reproduces on published 7.1.1). Add a cjs build output at dist/index.cjs (mirroring @mcp-ui/server) and point main/exports.require at it. The UMD bundle stays at dist/index.js for script-tag/CDN consumers. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent b8f2d4a commit 2b10490

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

sdks/typescript/client/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"description": "mcp-ui Client SDK",
55
"private": false,
66
"type": "module",
7-
"main": "./dist/index.js",
7+
"main": "./dist/index.cjs",
88
"module": "./dist/index.mjs",
99
"types": "./dist/src/index.d.ts",
1010
"exports": {
1111
".": {
1212
"types": "./dist/src/index.d.ts",
1313
"import": "./dist/index.mjs",
14-
"require": "./dist/index.js"
14+
"require": "./dist/index.cjs"
1515
}
1616
},
1717
"files": [

sdks/typescript/client/vite.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ export default defineConfig({
1717
lib: {
1818
entry: path.resolve(__dirname, 'src/index.ts'),
1919
name: 'McpUiClient',
20-
formats: ['es', 'umd'],
20+
// cjs for Node require() compatibility ("type": "module" makes .js files
21+
// ESM, so the UMD bundle at index.js is not requirable); umd kept for
22+
// script-tag/CDN consumers
23+
formats: ['es', 'cjs', 'umd'],
2124
fileName: (format) =>
22-
`index.${format === 'es' ? 'mjs' : format === 'umd' ? 'js' : format + '.js'}`,
25+
`index.${format === 'es' ? 'mjs' : format === 'cjs' ? 'cjs' : 'js'}`,
2326
},
2427
rollupOptions: {
2528
external: [

0 commit comments

Comments
 (0)