fix: add root src/index.ts so the advertised root export resolves (#2273) - #2632
Open
ousamabenyounes wants to merge 1 commit into
Open
fix: add root src/index.ts so the advertised root export resolves (#2273)#2632ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
…delcontextprotocol#2273) package.json maps the `.` export to dist/{esm,cjs}/index.{js,d.ts}, but v1.x had no src/index.ts, so tsc emitted nothing for the root and both `import '@modelcontextprotocol/sdk'` and `require('@modelcontextprotocol/sdk')` threw ERR_MODULE_NOT_FOUND before consumer code ran. Add a side-effect-free root barrel re-exporting ./types.js and ./inMemory.js; Client and Server stay on their ./client / ./server subpaths to avoid ambiguous re-export collisions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 858f5d7 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2273
package.json(v1.x) advertises a root.export:but there was no
src/index.ts, sotscnever emitted those files and they were absent from the published tarball. Both an ESMimportand a CJSrequireof the package root threwERR_MODULE_NOT_FOUNDbefore any consumer code ran. Subpath exports (/client,/server, …) were unaffected.This adds a side-effect-free root barrel per the direction in the issue triage:
export * from './types.js'— protocol types, schemas, constantsexport * from './inMemory.js'—InMemoryTransportClientandServerintentionally stay on their./client/./serversubpath exports to avoidTS2308ambiguous re-export collisions. The change is additive and non-breaking;mainis unaffected (it is a monorepo with no root package).Test verification (RED → GREEN)
New regression test
test/issues/test_2273_root_export.test.tsimports the root barrel and asserts it resolves and re-exports the protocol surface + a workingInMemoryTransport.RED — new test on unmodified
v1.x(nosrc/index.ts):GREEN — with
src/index.tsadded:End-to-end packaging check — after
npm run build, the previously-missing root files now emit and both loaders resolve:Full local suite
npm run typecheck(tsgo),npm run lint(eslint + prettier),npm run build,npm test(vitest): all green.52 files / 1639 tests→ with fix53 files / 1642 tests(+1 file, +3 new tests, 0 failures).Files changed
src/index.ts./types.js+./inMemory.jstest/issues/test_2273_root_export.test.ts.changeset/fix-root-export-missing-index.md