nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Make the PDF/DOCX stack of `@nanocollective/get-md` optional (110 MB of the 218 MB install)

Open addyCooks opened this issue 1 month ago • 1 comments

Description

Half of the install is one dependency. @nanocollective/get-md is used only by fetch_url (HTML to markdown) and when reading PDF/DOCX files. It is already imported lazily, so it costs nothing at runtime, but every user pays the disk space and install time. That hurts on small SSDs, slow networks and CI.

Environment

  • OS: Windows 11 (10.0.26300)
  • Node version: 22.22.3
  • Nanocoder version: 1.31.0 (main at 5c2e6935)

Evidence

  • Production closure: 337 packages, 217.8 MB. get-md accounts for 110.2 MB (50.6%): @napi-rs/canvas-win32-x64-msvc 35.0 MB (per-OS binary), pdfjs-dist 34.9 MB, pdf-parse 20.3 MB, @mixmark-io/domino 7.4 MB, happy-dom-without-node 4.3 MB, and a second undici (7.29.1, 1.6 MB).
  • Only two call sites, both await import('@nanocollective/get-md'): source/tools/fetch-url.tsx:105 and source/utils/file-cache.ts:159.
  • get-md is owned by the same organisation, so the split can be done upstream.

Proposed Change

  • Preferred: upstream get-md into a core (HTML) entry and a separate optional PDF entry, with pdfjs-dist, pdf-parse and @napi-rs/canvas as optional peers.
  • In nanocoder, treat the PDF path as optional. When a PDF/DOCX is read without the extra packages, return a clear message with the install command, or add a nanocoder add pdf helper.
  • Alternative: optionalDependencies, so a failed native install does not break installs.

Expected Behavior

  • A default install is at least 100 MB smaller.
  • fetch_url still converts HTML pages with the default install.
  • Reading a PDF works when the extra package is installed; without it the message is clear.

Additional Context

  • Effort: M. Start with package.json, source/tools/fetch-url.tsx, source/utils/file-cache.ts, and the Nano-Collective/get-md repo.
  • User-facing change: PDF/DOCX readers need an extra install step. Needs a docs update and a maintainer decision.
  • Exact savings differ per platform because @napi-rs/canvas ships a per-OS binary.

addyCooks avatar Oct 15 '26 15:10 addyCooks

@addyCooks assign me please i fix it tomorrow

Dhirenderchoudhary avatar Oct 16 '26 16:10 Dhirenderchoudhary