Skip to content

Replace tar-stream with leaner tar producer (~4.4 MB disk → ~zero) #450

Open

Description

@melvincarvalho

Context

#449 added tar-stream@^3.2.0 for the pod data export endpoint. It's working and tested, but Copilot's review (and a closer look during that PR) surfaced that the npm install footprint is meaningfully larger than originally claimed:

  • tar-stream: 60K
  • streamx: 64K
  • bare-fs: 1.4M
  • bare-os: 1.0M
  • bare-url: 1.6M
  • bare-events, bare-path, bare-stream: ~210K combined
  • b4a: 80K

Total: ~4.4 MB on disk added by one dep.

Functional impact on Node is zero — the bare-* family exists for the Bare runtime (a Node-alternative for embedded / RN) and is lazy-loaded only when running there. On Node, streamx falls back to readable-stream and the bare-* packages sit on disk but never load. So runtime weight is the 60K of tar-stream itself.

But the disk hit matters for our deployment targets — Termux/mobile, embedded servers, anywhere install footprint is a constraint. JSS otherwise stays lean (no native bindings, small dep tree); this single addition is disproportionately heavy.

Options

  1. Hand-roll tar producer. POSIX ustar is a well-specified format (~200 lines of streaming code: 512-byte header per entry with name/size/mode/checksum, file bytes padded to 512, two zero blocks at end). Zero deps, full control. Maintenance burden is real but small — tar format is stable.
  2. Find a leaner alternative. node-tar has its own dep tree; would need to compare carefully. No obvious drop-in that's strictly smaller.
  3. Strip optional bare-* peers at install time via .npmrc or similar. Brittle; depends on npm/pnpm version.
  4. Accept the hit. Document it clearly (already done in feat: GET /idp/account/export — self-service pod data download (#353) #449 PR description) and move on. Disk is cheap on most targets, it's only mobile/embedded where this matters.

Recommendation: option 1 (hand-roll) feels right for the project's lean-deps ethos, but it's a focused chunk of work that wasn't right for #449's scope.

Acceptance

  • Replace tar-stream import in src/idp/export.js with the new producer.
  • All 6 tests in test/idp-export.test.js still pass (they extract via tar-stream on the test side — test-only dep, fine to keep).
  • npm install adds <500K to node_modules.
  • package.json and package-lock.json no longer carry the bare-* family.

Out of scope

Follow-up to #449.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions