-
Notifications
You must be signed in to change notification settings - Fork 1
fix(mcpb): bundle contains 80MB+ of unnecessary dependencies (84MB → ~10MB target) #183
Description
Problem
The MCPB bundle (gitlab-mcp-6.41.1.mcpb) is 84 MB compressed / 281 MB uncompressed with 13,433 files.
Root Causes
-
prismaindependencies— The Prisma CLI is only needed forprisma generateduring build, not at runtime. Being independenciesmeansnpm install --productioninstalls it and ALL its transitive deps (typescript, @electric-sql, effect, chevrotain, etc.) -
@prisma/clientdeclaresprismaas peerDependency — npm 7+ auto-installs peer deps even with--production, pulling in the CLI again. -
Unused packages in
dependencies—form-data(never imported, Node.js has native FormData),@graphql-typed-document-node/core(type-only imports, erased at compile time). -
build-mcpb.shdoesn't clean up enough — Only removes*.md,LICENSE*,__tests__/but leaves source maps,.d.ts, fixture directories.
Solution
Step 1: Move build-only packages to devDependencies
prisma— only needed forprisma generateduring build@graphql-typed-document-node/core— type-only imports (erased at compile time)
Step 2: Remove unused packages
form-data— never imported in src/, Node.js 24 has native FormData
Step 3: Use --omit=peer in npm install
Prevents npm from auto-installing prisma CLI and typescript as @prisma/client peer dependencies.
Step 4: Enhanced cleanup in build-mcpb.sh
- Remove source maps (
*.js.map) from node_modules and dist/ - Remove TypeScript declarations (
*.d.ts,*.d.mts) from node_modules - Remove fixture/example/doc directories
- Remove
package-lock.json,tsconfig.build.tsbuildinfo
Result
| Before | After | Reduction |
|---|---|---|
| 84 MB compressed | ~45 MB compressed | ~47% smaller |
Files Modified
| File | Change |
|---|---|
package.json |
Move prisma, @graphql-typed-document-node/core to devDeps; remove form-data |
scripts/build-mcpb.sh |
--omit=peer + enhanced cleanup |