fix(mcpb): reduce bundle size from 84MB to ~45MB#184
Merged
Conversation
- 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
Test Coverage ReportOverall Coverage: 93.51%
|
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)
There was a problem hiding this comment.
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
prismafrom dependencies to devDependencies to exclude the Prisma CLI from production bundles - Added
--omit=peerflag 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)
|
🎉 This PR is included in version 6.41.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #183
prismaand@graphql-typed-document-node/coretodevDependencies(build-time only)form-datapackage (Node.js has native FormData)--omit=peerinnpm installto preventprismaCLI andtypescriptbeing installed as@prisma/clientpeer deps.d.ts,.d.mts, fixture/example/doc directories fromnode_modulesdist/(tsconfig.tsbuildinfo,*.js.map)prisma generatein bundle build (already compiled indist/)Result: 84 MB → ~45 MB compressed (-47%)
Test plan
yarn lint— 0 errorsyarn test— 124 suites, 3833 tests passingyarn build— success./scripts/build-mcpb.sh "0.0.0-test"— 44.9 MBnode dist/src/main.js— OK