48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { defineConfig } from 'tsup';
|
|
import { resolve, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
export default defineConfig({
|
|
entry: ['src/index.ts'],
|
|
format: ['esm'],
|
|
target: 'es2022',
|
|
outDir: 'dist',
|
|
clean: true,
|
|
sourcemap: true,
|
|
dts: true,
|
|
bundle: true,
|
|
noExternal: [/.*/],
|
|
banner: { js: '#!/usr/bin/env node' },
|
|
esbuildPlugins: [
|
|
{
|
|
name: 'fix-mcp-sdk-deps',
|
|
setup(build) {
|
|
const explicitExports = new Set(['server', 'client', 'validation', 'experimental']);
|
|
build.onResolve({ filter: /^@modelcontextprotocol\/sdk\/.+/ }, (args) => {
|
|
const subpath = args.path.replace('@modelcontextprotocol/sdk/', '');
|
|
const topLevel = subpath.split('/')[0];
|
|
if (explicitExports.has(topLevel) && !subpath.includes('/')) return undefined;
|
|
return {
|
|
path: resolve(
|
|
__dirname,
|
|
'node_modules/@modelcontextprotocol/sdk/dist/esm',
|
|
subpath + '.js',
|
|
),
|
|
};
|
|
});
|
|
|
|
build.onResolve({ filter: /^ajv-formats/ }, (args) => {
|
|
return { path: args.path, namespace: 'ajv-stub' };
|
|
});
|
|
build.onResolve({ filter: /^ajv\/dist\// }, (args) => {
|
|
return { path: args.path, namespace: 'ajv-stub' };
|
|
});
|
|
build.onLoad({ filter: /.*/, namespace: 'ajv-stub' }, () => {
|
|
return { contents: 'module.exports = function() {};', loader: 'js' };
|
|
});
|
|
},
|
|
},
|
|
],
|
|
});
|