-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix: Barrel file exports #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix: Barrel file exports #870
Conversation
…lcontextprotocol/sdk/client and @modelcontextprotocol/sdk/shared
@cliffhall @ihrpr this is an extension to #851 |
This looks good to me in this view. One important thing for reviewers to do is make certain that the new |
Let's include it in V2 |
@ihrpr maybe we could add a |
I'm marking those PRs with V2 milestone |
I came here to open this PR :) Thanks for doing this. |
I have to say I was thinking of /sdk/types myself before comitting... But if you do look at it, it really isn't just types that's in there. The current sdk v1 unfortunately mixes types and runtime code in files. So even in your types.ts you will find runtime code. And other files that are exported (from the shared folder) certainly have loads of runtime (and id say much more runtime than types) Exporting something via /sdk/types "implies" as a user I would be able to put that in devDependencies let's say, or alternatively to be importing it via "import type * from @modelcontextprotocol/sdk/types". However its not the case here due to the majority of the code being runtime and not just types.. We could, still decide to do it via /sdk/types however I dont think the regular user will expect that, given what it actually contains. (Classes, schemas, methods etc. as opposed to the expectation implied which is it should be just types, interfaces etc)
|
I have seen types 'mixed in' with everything else in other libraries, but I'm not sure I like it. There's no indicators (that I know of) that give you the hint that you could pull in something like:
To your point, and maybe eventually, there is an Anyway, I'm not sure I have a horse in this race, but glad it's being worked on :) |
Extension to #851 and #511
Motivation and Context
The SDK currently exports from all files, which leads to users/implementors having to import from multiple places from the SDK.
Example:
This PR introduced index.ts barrel files under the following namespaces:
The above snippet would now look like:
How Has This Been Tested?
Unit tests continue to run with no issues.
Breaking Changes
No, it's an improvement and not a breaking change.
Types of changes
Checklist
Additional context
There are two files which were a bit controversial "./types.ts", and "./inMemory.ts". These are currently residing at the root level, although they are really "shared". Thus the shared namespace is re-exporting them.
Additionally, the previous client/index.ts contents was moved to client/client.ts and server/index.ts was moved to server/server.ts respectively. Since these two files are now re-exported by the index.ts files, there is no breaking change.