Skip to content

fix: shrink npm tarball by excluding sharp and pruning standalone#136

Merged
NiveditJain merged 1 commit into
mainfrom
luv-136
Apr 22, 2026
Merged

fix: shrink npm tarball by excluding sharp and pruning standalone#136
NiveditJain merged 1 commit into
mainfrom
luv-136

Conversation

@NiveditJain

Copy link
Copy Markdown
Member

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.3 seen ~49 s after publish completed; investigation traced the root cause to oversized artifacts (34 MB of @img/sharp native binaries + over-traced project files) bundled into .next/standalone/ by Next.js NFT.

Changes

  • 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 binaries NFT was tracing in as an optional dep is dead weight.
  • scripts/prune-standalone.mjs (new): post-build pass that
    1. removes @img/sharp belt-and-suspenders in case NFT still catches them on some Turbopack version,
    2. strips .md/.map/test dirs/changelogs from bundled node_modules/,
    3. deletes over-traced project artifacts (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.mjs to the build script.
  • CHANGELOG.md: entry under ## Unreleased### Fixes.

Test plan

  • bun run build — clean build, prune logs 1632 files / 20.32 MB -> 1270 files / 17.82 MB (saved 362 files / 2.50 MB)
  • node .next/standalone/server.js — dashboard boots: / → 307 → /policies, /policies returns 200 with 23.6 KB HTML, /projects returns 200
  • bun run test:run — 965/965 unit tests pass across 52 files
  • bun run test:e2e — 207/207 e2e tests pass across 6 files
  • Docker clean-install smoke test per CLAUDE.md — failproofai --version returns 0.0.6-beta.4, failproofai p -i -c /tmp/test-policy.mjs validates the custom hook
  • npm pack --dry-run — package size 4.1 MB, unpacked 19.2 MB, 1342 files

🤖 Generated with Claude Code

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.
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@NiveditJain has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 20 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d552e055-867e-4207-92c4-776aa5444ac6

📥 Commits

Reviewing files that changed from the base of the PR and between cb3e5e3 and 46b1aec.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • next.config.ts
  • package.json
  • scripts/prune-standalone.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luv-136

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@NiveditJain NiveditJain merged commit 247b528 into main Apr 22, 2026
9 checks passed
@NiveditJain NiveditJain deleted the luv-136 branch April 27, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant