fix(core): move @cfworker/json-schema out of main barrel into /validators/cf-worker subpath (#1897)
This commit is contained in:
parent
b256546750
commit
434b2f11ec
14 changed files with 38 additions and 12 deletions
6
.changeset/cfworker-out-of-barrel.md
Normal file
6
.changeset/cfworker-out-of-barrel.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@modelcontextprotocol/server': patch
|
||||
'@modelcontextprotocol/client': patch
|
||||
---
|
||||
|
||||
Stop bundling `@cfworker/json-schema` into the main package barrel. Previously `CfWorkerJsonSchemaValidator` was re-exported from the core internal barrel, so tsdown inlined the `@cfworker/json-schema` dev dependency into every consumer's bundle even when it was never used. The validator is now reachable only via the `_shims` conditional (workerd/browser) and the explicit `@modelcontextprotocol/{server,client}/validators/cf-worker` subpath, so consumers that don't opt into it no longer ship that code. No public API change.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is selected via package.json export conditions when running in a browser.
|
||||
*/
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
|
||||
/**
|
||||
* Whether `fetch()` may throw `TypeError` due to CORS. Only true in browser contexts
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is selected via package.json export conditions when running in workerd.
|
||||
*/
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
|
||||
/**
|
||||
* Whether `fetch()` may throw `TypeError` due to CORS. CORS is a browser-only concept —
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@
|
|||
* import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/client/validators/cf-worker';
|
||||
* ```
|
||||
*/
|
||||
export { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
export type { CfWorkerSchemaDraft } from '@modelcontextprotocol/core';
|
||||
export type { CfWorkerSchemaDraft } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
export { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
"*": ["./*"],
|
||||
"@modelcontextprotocol/core": ["./node_modules/@modelcontextprotocol/core/src/index.ts"],
|
||||
"@modelcontextprotocol/core/public": ["./node_modules/@modelcontextprotocol/core/src/exports/public/index.ts"],
|
||||
"@modelcontextprotocol/core/validators/cfWorker": [
|
||||
"./node_modules/@modelcontextprotocol/core/src/validators/cfWorkerProvider.ts"
|
||||
],
|
||||
"@modelcontextprotocol/test-helpers": ["./node_modules/@modelcontextprotocol/test-helpers/src/index.ts"],
|
||||
"@modelcontextprotocol/client/_shims": ["./src/shimsNode.ts"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ export default defineConfig({
|
|||
baseUrl: '.',
|
||||
paths: {
|
||||
'@modelcontextprotocol/core': ['../core/src/index.ts'],
|
||||
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts']
|
||||
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts'],
|
||||
'@modelcontextprotocol/core/validators/cfWorker': ['../core/src/validators/cfWorkerProvider.ts']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
"./public": {
|
||||
"types": "./src/exports/public/index.ts",
|
||||
"import": "./src/exports/public/index.ts"
|
||||
},
|
||||
"./validators/cfWorker": {
|
||||
"types": "./src/validators/cfWorkerProvider.ts",
|
||||
"import": "./src/validators/cfWorkerProvider.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,11 @@ export * from './util/standardSchema.js';
|
|||
// experimental exports
|
||||
export * from './experimental/index.js';
|
||||
export * from './validators/ajvProvider.js';
|
||||
export * from './validators/cfWorkerProvider.js';
|
||||
// cfWorkerProvider is intentionally NOT re-exported here: it statically imports
|
||||
// `@cfworker/json-schema` (an optional peer), and bundling it into the main barrel
|
||||
// would force that import on all Node consumers. Import via `@modelcontextprotocol/core/validators/cfWorker`
|
||||
// (used by the workerd/browser `_shims` and the public `/validators/cf-worker` subpaths).
|
||||
export type { CfWorkerSchemaDraft } from './validators/cfWorkerProvider.js';
|
||||
export * from './validators/fromJsonSchema.js';
|
||||
/**
|
||||
* JSON Schema validation
|
||||
|
|
@ -30,7 +34,7 @@ export * from './validators/fromJsonSchema.js';
|
|||
* - {@linkcode AjvJsonSchemaValidator}: Best for Node.js (default, fastest)
|
||||
* Bundled — no additional dependencies required.
|
||||
*
|
||||
* - {@linkcode CfWorkerJsonSchemaValidator}: Best for edge runtimes
|
||||
* - `CfWorkerJsonSchemaValidator`: Best for edge runtimes
|
||||
* Import from: `@modelcontextprotocol/server/validators/cf-worker` or `@modelcontextprotocol/client/validators/cf-worker`
|
||||
* Bundled — no additional dependencies required.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is selected via package.json export conditions when running in workerd.
|
||||
*/
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
export { CfWorkerJsonSchemaValidator as DefaultJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
|
||||
/**
|
||||
* Stub process object for non-Node.js environments.
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@
|
|||
* import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker';
|
||||
* ```
|
||||
*/
|
||||
export { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/core';
|
||||
export type { CfWorkerSchemaDraft } from '@modelcontextprotocol/core';
|
||||
export type { CfWorkerSchemaDraft } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
export { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
"*": ["./*"],
|
||||
"@modelcontextprotocol/core": ["./node_modules/@modelcontextprotocol/core/src/index.ts"],
|
||||
"@modelcontextprotocol/core/public": ["./node_modules/@modelcontextprotocol/core/src/exports/public/index.ts"],
|
||||
"@modelcontextprotocol/core/validators/cfWorker": [
|
||||
"./node_modules/@modelcontextprotocol/core/src/validators/cfWorkerProvider.ts"
|
||||
],
|
||||
"@modelcontextprotocol/test-helpers": ["./node_modules/@modelcontextprotocol/test-helpers/src/index.ts"],
|
||||
"@modelcontextprotocol/server/_shims": ["./src/shimsNode.ts"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ export default defineConfig({
|
|||
baseUrl: '.',
|
||||
paths: {
|
||||
'@modelcontextprotocol/core': ['../core/src/index.ts'],
|
||||
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts']
|
||||
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts'],
|
||||
'@modelcontextprotocol/core/validators/cfWorker': ['../core/src/validators/cfWorkerProvider.ts']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
import { Client } from '@modelcontextprotocol/client';
|
||||
import type { ElicitRequestFormParams } from '@modelcontextprotocol/core';
|
||||
import { AjvJsonSchemaValidator, CfWorkerJsonSchemaValidator, InMemoryTransport } from '@modelcontextprotocol/core';
|
||||
import { AjvJsonSchemaValidator, InMemoryTransport } from '@modelcontextprotocol/core';
|
||||
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/core/validators/cfWorker';
|
||||
import { Server } from '@modelcontextprotocol/server';
|
||||
|
||||
const ajvProvider = new AjvJsonSchemaValidator();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
"*": ["./*"],
|
||||
"@modelcontextprotocol/core": ["./node_modules/@modelcontextprotocol/core/src/index.ts"],
|
||||
"@modelcontextprotocol/core/public": ["./node_modules/@modelcontextprotocol/core/src/exports/public/index.ts"],
|
||||
"@modelcontextprotocol/core/validators/cfWorker": [
|
||||
"./node_modules/@modelcontextprotocol/core/src/validators/cfWorkerProvider.ts"
|
||||
],
|
||||
"@modelcontextprotocol/client": ["./node_modules/@modelcontextprotocol/client/src/index.ts"],
|
||||
"@modelcontextprotocol/client/_shims": ["./node_modules/@modelcontextprotocol/client/src/shimsNode.ts"],
|
||||
"@modelcontextprotocol/server": ["./node_modules/@modelcontextprotocol/server/src/index.ts"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue