mindee-api-nodejs icon indicating copy to clipboard operation
mindee-api-nodejs copied to clipboard

Make PDF & image compression optional (remove mandatory dependencies on ‎`sharp`, ‎`node-poppler`, ‎`pdf.js-extract`)

Open ck-developer opened this issue 2 months ago • 2 comments
trafficstars

Description

Currently, the Mindee Node.js SDK requires heavy native dependencies (‎sharp, ‎node-poppler, ‎pdf.js-extract) for PDF and image compression. These are installed by default, even if the consuming project does not use any compression features. This increases install time, package size, and causes compatibility issues on some environments (especially with native bindings).

Expected Behavior • The SDK should not require ‎sharp, ‎node-poppler, or ‎pdf.js-extract unless the compression features are explicitly used. • Ideally, compression should be implemented as an optional plugin, peer dependency, or loaded dynamically. • If compression is not available, the SDK should gracefully fallback (no-op or informative error).

Proposed Solution • Refactor the SDK so that: ▫ Compression logic is isolated in a separate file/module. ▫ Dependencies (‎sharp, ‎node-poppler, ‎pdf.js-extract) are either optional peer dependencies or moved to a plugin. ▫ The main SDK package can be installed and used without these dependencies. ▫ If a user tries to call compression without the deps, throw a clear error or do nothing.

Benefits • Faster installation and smaller package size for most users. • Fewer native dependency issues. • Easier integration in environments where native modules are problematic (e.g., serverless, Docker, Windows).

ck-developer avatar Sep 17 '25 12:09 ck-developer

This is something we were thinking about, and is pretty much what was done with the PHP lib, but this isn't something we can prioritize at the moment.

We'll be discussing it internally some time in the future when other libs & tools are all up to date for V2.

CC @ianardee

sebastianMindee avatar Sep 17 '25 14:09 sebastianMindee

In addition to @sebastianMindee 's comment, this would likely be a breaking change.

It is a good idea though, we'll look into when working on the next major version.

ianardee avatar Sep 17 '25 14:09 ianardee