Skip to content

fix(mcpb): reduce bundle size from 84MB to ~45MB#184

Merged
polaz merged 3 commits intomainfrom
feat/#183-fixmcpb-bundle-contains-80mb-of-unnecessary-depend
Jan 24, 2026
Merged

fix(mcpb): reduce bundle size from 84MB to ~45MB#184
polaz merged 3 commits intomainfrom
feat/#183-fixmcpb-bundle-contains-80mb-of-unnecessary-depend

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 24, 2026

Summary

Closes #183

  • Move prisma and @graphql-typed-document-node/core to devDependencies (build-time only)
  • Remove unused form-data package (Node.js has native FormData)
  • Use --omit=peer in npm install to prevent prisma CLI and typescript being installed as @prisma/client peer deps
  • Enhanced cleanup in build-mcpb.sh: remove source maps, .d.ts, .d.mts, fixture/example/doc directories from node_modules
  • Remove build artifacts from dist/ (tsconfig.tsbuildinfo, *.js.map)
  • Skip prisma generate in bundle build (already compiled in dist/)
  • Bump pino 10.3.0, undici 7.19.1, @cloudflare/workers-types

Result: 84 MB → ~45 MB compressed (-47%)

Test plan

  • yarn lint — 0 errors
  • yarn test — 124 suites, 3833 tests passing
  • yarn build — success
  • ./scripts/build-mcpb.sh "0.0.0-test" — 44.9 MB
  • Server starts correctly: node dist/src/main.js — OK

- Move prisma to devDependencies (not needed at runtime)
- Use --omit=peer in npm install to prevent prisma CLI peer dep bloat
- Strip non-SQLite Prisma WASM runtimes (sqlserver, cockroachdb, postgresql, mysql)
- Remove source maps, .d.ts, fixtures, test dirs from node_modules
- Remove build artifacts (tsconfig.tsbuildinfo, dist/*.js.map)
- Skip prisma generate in bundle (already compiled in dist/)
- Add bundle size CI check (max 30 MB)
- Update pino 10.3.0, undici 7.19.1, @cloudflare/workers-types
Copilot AI review requested due to automatic review settings January 24, 2026 15:45
@github-actions
Copy link
Copy Markdown

Test Coverage Report

Overall Coverage: 93.51%

Metric Percentage
Statements 93.02%
Branches 84.78%
Functions 82.85%
Lines 93.51%

View detailed coverage report

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- Project uses PostgreSQL (not SQLite) — keep postgresql WASM, strip
  sqlserver/cockroachdb/sqlite/mysql instead
- Remove bundle size CI step (unnecessary overhead)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce the MCPB (Model Context Protocol Bundle) size from 84MB to approximately 25MB by moving prisma to devDependencies, using --omit=peer to prevent unnecessary peer dependency installation, stripping unused Prisma WASM database runtimes, and performing aggressive cleanup of documentation, test files, source maps, and TypeScript declarations from node_modules.

Changes:

  • Moved prisma from dependencies to devDependencies to exclude the Prisma CLI from production bundles
  • Added --omit=peer flag to npm install to prevent automatic installation of peer dependencies like the Prisma CLI and TypeScript
  • Implemented stripping of unused Prisma WASM runtimes and enhanced cleanup of unnecessary files (docs, tests, source maps, TypeScript declarations, fixtures, examples)
  • Added CI validation to ensure MCPB bundle size stays under 30MB
  • Bumped minor dependency versions (pino 10.3.0, undici 7.19.1, @cloudflare/workers-types 4.20260124.0)

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
package.json Moved prisma to devDependencies, updated pino, undici, and @cloudflare/workers-types to newer versions
scripts/build-mcpb.sh Removed prisma generate step in bundle, added --omit=peer flag, implemented WASM runtime stripping and aggressive cleanup, enhanced size reporting
.github/workflows/ci-cd.yml Added MCPB bundle size validation step with 30MB limit
yarn.lock Lock file updates reflecting dependency version changes

…Deps

- Remove Prisma WASM runtime stripping entirely (keep all runtimes)
- Remove form-data from deps (unused, Node.js has native FormData)
- Move @graphql-typed-document-node/core to devDeps (type-only imports)
- Keep @clack/prompts and open in deps (needed for npm CLI usage)
@polaz polaz changed the title fix(mcpb): reduce bundle size from 84MB to ~25MB fix(mcpb): reduce bundle size from 84MB to ~45MB Jan 24, 2026
@polaz polaz requested a review from Copilot January 24, 2026 16:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

@polaz polaz merged commit 37f9c29 into main Jan 24, 2026
22 checks passed
@polaz polaz deleted the feat/#183-fixmcpb-bundle-contains-80mb-of-unnecessary-depend branch January 24, 2026 16:09
sw-release-bot bot pushed a commit that referenced this pull request Jan 24, 2026
## [6.41.2](v6.41.1...v6.41.2) (2026-01-24)

### Bug Fixes

* **ci:** remove generated artifacts from repo, fix MCPB 404 race condition ([#181](#181)) ([#182](#182)) ([6f17c99](6f17c99))
* **mcpb:** reduce bundle size from 84MB to ~45MB ([#184](#184)) ([37f9c29](37f9c29)), closes [#183](#183)
@sw-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 6.41.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants