include node modules while building mcp ui

This commit is contained in:
Fredrik Jensen 2025-12-06 17:37:37 +01:00
parent fbc5588c78
commit 03e720f5dc

View File

@ -7,6 +7,16 @@ const bundleCache = new Map<string, string>();
const isDev = process.env.NODE_ENV !== 'production'; const isDev = process.env.NODE_ENV !== 'production';
async function runBuild(entryPath: string): Promise<esbuild.BuildResult<{ write: false }>> { async function runBuild(entryPath: string): Promise<esbuild.BuildResult<{ write: false }>> {
// Resolve node_modules paths - check both the entry's directory and common locations
const path = await import('path');
const entryDir = path.dirname(entryPath);
const nodePaths = [
path.join(entryDir, 'node_modules'),
path.join(entryDir, '..', 'node_modules'),
path.join(entryDir, '..', '..', 'node_modules'),
path.join(process.cwd(), 'node_modules'),
];
return esbuild.build({ return esbuild.build({
entryPoints: [entryPath], entryPoints: [entryPath],
bundle: true, bundle: true,
@ -19,6 +29,7 @@ async function runBuild(entryPath: string): Promise<esbuild.BuildResult<{ write:
'.ts': 'ts', '.ts': 'ts',
}, },
minify: !isDev, minify: !isDev,
nodePaths,
}); });
} }