fix: shrink npm tarball by excluding sharp and pruning standalone#136
Conversation
The published package was 20.3 MB packed / 56.4 MB unpacked / 1761 files, dominated by .next/standalone/ (55.9 MB). This cuts it to ~4 MB packed / ~19 MB unpacked / ~1340 files without changing runtime behavior. - next.config.ts: add outputFileTracingExcludes for node_modules/@img and node_modules/sharp. Image optimization is already disabled globally (images.unoptimized: true), so the 34 MB of sharp native binaries NFT was tracing in as an optional dep is dead weight. - scripts/prune-standalone.mjs: post-build pass that (a) removes @img/sharp belt-and-suspenders, (b) strips .md/.map/test dirs/changelogs from bundled node_modules, and (c) deletes over-traced project artifacts (docs/, src/, scripts/, dist/, bin/, examples/, agent configs, root markdown, build/lint/test configs, bun.lock) that Next.js NFT pulls into standalone but the runtime never reads. - package.json: append `&& node scripts/prune-standalone.mjs` to the build script so it runs after `next build` + the static copy step. Verified: dashboard still boots (node .next/standalone/server.js serves /policies and /projects with HTTP 200), 965 unit tests pass, 207 e2e tests pass, Docker clean-install smoke test succeeds.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 20 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The published npm package was 20.3 MB packed / 56.4 MB unpacked / 1761 files, dominated by
.next/standalone/(55.9 MB). This shrinks it to ~4.1 MB packed / ~19.2 MB unpacked / ~1342 files — a ~5x reduction in packed size — with zero runtime behavior change.Motivated by a user report of
ETARGET: No matching version found for failproofai@0.0.6-beta.3seen ~49 s after publish completed; investigation traced the root cause to oversized artifacts (34 MB of@img/sharpnative binaries + over-traced project files) bundled into.next/standalone/by Next.js NFT.Changes
next.config.ts: addoutputFileTracingExcludesfornode_modules/@img/**andnode_modules/sharp/**. Image optimization is already disabled globally (images.unoptimized: true), so the 34 MB of sharp binaries NFT was tracing in as an optional dep is dead weight.scripts/prune-standalone.mjs(new): post-build pass that@img/sharpbelt-and-suspenders in case NFT still catches them on some Turbopack version,.md/.map/test dirs/changelogs from bundlednode_modules/,docs/,src/,scripts/,dist/,bin/,examples/, agent configs, root markdown, build/lint/test configs,bun.lock) from the standalone root that NFT pulls in but the runtime never reads.package.json: append&& node scripts/prune-standalone.mjsto thebuildscript.CHANGELOG.md: entry under## Unreleased→### Fixes.Test plan
bun run build— clean build, prune logs1632 files / 20.32 MB -> 1270 files / 17.82 MB (saved 362 files / 2.50 MB)node .next/standalone/server.js— dashboard boots:/→ 307 →/policies,/policiesreturns 200 with 23.6 KB HTML,/projectsreturns 200bun run test:run— 965/965 unit tests pass across 52 filesbun run test:e2e— 207/207 e2e tests pass across 6 filesfailproofai --versionreturns0.0.6-beta.4,failproofai p -i -c /tmp/test-policy.mjsvalidates the custom hooknpm pack --dry-run— package size 4.1 MB, unpacked 19.2 MB, 1342 files🤖 Generated with Claude Code