Skip to content

fix(mcpb): bundle contains 80MB+ of unnecessary dependencies (84MB → ~10MB target) #183

@polaz

Description

@polaz

Problem

The MCPB bundle (gitlab-mcp-6.41.1.mcpb) is 84 MB compressed / 281 MB uncompressed with 13,433 files.

Root Causes

  1. prisma in dependencies — The Prisma CLI is only needed for prisma generate during build, not at runtime. Being in dependencies means npm install --production installs it and ALL its transitive deps (typescript, @electric-sql, effect, chevrotain, etc.)

  2. @prisma/client declares prisma as peerDependency — npm 7+ auto-installs peer deps even with --production, pulling in the CLI again.

  3. Unused packages in dependenciesform-data (never imported, Node.js has native FormData), @graphql-typed-document-node/core (type-only imports, erased at compile time).

  4. build-mcpb.sh doesn'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 for prisma generate during 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions