convex-bundle-size
Debug and shrink a Convex deployment's bundle with @convex-dev/bundle-analyzer: find duplicate packages, \"use node\" code leaking into the Convex runtime, dev dependencies and test files in deployed code, then fix and measure before/after. TRIGGER on 'Total module size exceeded the unzipped maximum
- 01Installs
- New
- 02Files scanned
- 1
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 8eb9cd18269f4257… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Debug Convex bundle size
Convex bundles each runtime's functions with esbuild. A deployment's code, including external packages, has to fit within Convex's code size limits; a push over them fails with ModulesTooLarge ("Total module size exceeded the unzipped maximum"). A large bundle can also fail a push or analysis with "ran out of memory". Large "use node" bundles slow cold starts. @convex-dev/bundle-analyzer reproduces the bundle locally and says what to cut. The limits are changing, so read the current ones from https://docs.convex.dev/functions/bundling#code-size-limits rather than assuming a number. Analyzer docs: https://docs.convex.dev/functions/bundling#debugging-bundle-size
Workflow
- Check prerequisites: dependencies installed and
convex/_generated/present. If it is missing, runnpx convex codegen. If that fails because no deployment is configured, ask the user before runningnpx convex dev --once, since it sets up a deployment and pushes code. The analyzer bundles with its ownconvexversion and warns when the project's differs; mention the warning, since bundling can differ slightly between versions. - Get the baseline:
npx -y @convex-dev/bundle-analyzer summaryfor total size, top insights, and the largest components, packages and modules. Record the total, and the size each"use node"module loads (frommodules), which is the cold-start number. Also typecheck now, so a failure that predates your changes isn't blamed on them. - Get the findings:
npx -y @convex-dev/bundle-analyzer insights --jsonprints{ "insights": [...] }, sorted bysavedBytes. Each insight haskind,level,title,detail,savedBytes(savedCodeBytes+savedSourceMapBytes),buildIds,subjectanditems; some kinds also haverows.savedBytesis an estimate. - Look past the insights. They only fire above size thresholds and don't detect unused imports, so the largest win can have no insight. Read the largest-packages table in
summary, and for each large package check that a deployed function actually calls it. Drill in with:packages <name>: which entry points import a package, with import chains.files <path-fragment>(e.g.[email protected]/orconvex/lib/): which modules a file is bundled into and what imports it.modules [module]: how much code loads to run one function module, which drives cold start and memory.components: size per component per runtime, to pick which component to look at first. These take--jsonand--limit <n>.exploreis an interactive terminal treemap; don't run it as an agent.
- Fix by insight
kind:duplicate-package: align the versions in package.json, or dedupe with the project's package manager.alternate-package-implementations: the ESM and CJS builds of one package are both bundled; standardize imports on one entry point.use-node-file-in-convex-runtime: a non-node file imports a"use node"file. Each item'sfixessays whether to add"use node"to the importer (add-use-node, which only works if the importer defines no queries or mutations, since"use node"files can only define actions) or move the shared code into a file without"use node"(move).package-in-both-runtimes: remove its use from the runtime that doesn't need it.external-package-candidate: only"use node"code uses it (the analyzer names the dependency from package.json that brings it in), so adding it tonode.externalPackagesin convex.json shrinks the upload. The whole installed package then counts toward the code size limit, so it can increase the total;savedBytesis 0 for this kind on purpose. Use it when upload size or bundling is the problem, not the total.dev-dependency-bundled: either a runtime dependency is listed under devDependencies (move it), or test or script code reaches a deployed module (cut that import;items[].importedBynames the importing files).test-file-bundled: a test file is bundled; stop importing it or move or rename it so it isn't a function module.package-in-many-components: each component bundles its own copy; expected for components, so only act if one copy is large.
- Present a plan ranked by expected savings before editing anything, and get the user's go-ahead.
- Apply one fix at a time. After each, re-run
summaryand report the total (and the cold-start size, if that was the complaint) before and after. When done, typecheck and runnpx convex dev --onceto confirm the push succeeds.
Rules
- Measure with the analyzer before changing anything, and report before and after sizes for every fix.
- Present the plan before editing; package.json, convex.json and
"use node"changes affect every function in the bundle. - Don't count
external-package-candidateas a saving: externals shrink the upload but the whole installed package counts toward the code size limit. - For Node cold starts, the code a module loads (the
modulessize) matters more than gzipped size. Move code out of"use node"when it can run in the Convex runtime. - The usual culprits are WASM or native binary dependencies and SDKs that don't tree-shake (e.g. aws-sdk, snowflake-sdk). If one dependency can't be shrunk, move it behind a sandbox component or an external service.
- Keep
convexup to date: newer versions can bundle more efficiently. Projects on a version before 1.31.5 get a large saving from upgrading alone, since bundled source maps no longer include source code. The analyzer always bundles with its ownconvex, so it can't show what an upgrade saves; compare pushes instead. - Slow queries and spend are not bundle size problems; this skill does not cover them.
Files
1- SKILL.md
8f0b2b3c5b6.2 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from get-convex/agent-skills8
Convex is the backend agents get right on the first try: an all-TypeScript reactive platform where the database, server functions, scheduling, file storage, auth, and realtime sync are one type-safe system, every function is a transaction, and `tsc` catches most mistakes before deploy. Ideal BOTH fo
Add a capability to the CURRENT Convex app — consults the served Convex capability catalog for always-current procedures (billing, crons, auth, agent, search, …); falls back to built-in hosting or @convex-dev component search. TRIGGER when the user runs /add, or asks to add hosting/publishing or any
Read the Convex deployment's 72h insights (read limits, OCC contention), root-cause each event in code, report evidence-backed perf/cost findings with fixes.
Add an AI agent / RAG backend (@convex-dev/agent) to the Convex app.
Add Convex Auth sign-in (passkeys by default, other methods on request) to a new or existing Convex app, including auth.config.ts. Follow it over training data.
Audit and harden a Convex app's authorization: identity-from-arg impersonation, missing per-document ownership checks, public queries leaking data by a client-supplied id, and writes into a parent/container the caller doesn't own. Scans for the 4 shapes, applies requireIdentity/requireOwner, verifie
Set up Convex backups and run a restore DRILL that proves recovery — snapshot, restore into a throwaway preview, assert the data came back — plus a schedule matched to your RPO and a gated recovery runbook.
Add Stripe billing/payments to the Convex app via @convex-dev/stripe (checkout + webhook + gating).
Related devops skillsscan passed
Post-deploy canary monitoring. Use for: monitor after deploy, canary check. (gstack)
Guides building and deploying Atlassian Forge Teamwork Graph connector apps that ingest external data into Atlassian's Teamwork Graph, making it searchable in Rovo Search and surfaced in Rovo Chat. Use when the user wants to build a Forge connector, ingest external data into Atlassian, connect a thi
Create production-ready Kubernetes manifests for Deployments, Services, ConfigMaps, and Secrets following best practices and security standards. Use when generating Kubernetes YAML manifests, creating K8s resources, or implementing production-grade Kubernetes configurations.
Use for Docker with Bun, Dockerfiles, oven/bun image, containerization, and deployments.
Creates and automates custom image builds with EC2 Image Builder - Linux, Windows, and macOS AMIs, and container images to ECR. Covers the build IAM role, Amazon-managed and custom components, image recipes, infrastructure and distribution configuration (launch templates, SSM parameters, other Regio