Skip to content

Make @napi-rs/canvas an optional dependency for text-only use cases #115

@kobbikobb

Description

@kobbikobb

Hi! Thanks for maintaining pdf-parse.

We use pdf-parse in a Node service that runs in Docker. We only call getText() for text extraction, never render to images. But @napi-rs/canvas is a hard dependency, which adds ~48MB of native binaries to our container.

Would you consider making @napi-rs/canvas an optional/peer dependency? Text extraction would work without it; rendering APIs would throw a clear error if it's not installed.

Quick options:

  1. optionalDependencies + runtime check in render code paths
  2. peerDependenciesMeta.optional: true
  3. Split exports — e.g. pdf-parse/text (no canvas) vs pdf-parse (full)

Happy to send a PR if you're open to any of these — let me know which direction you'd prefer.

Either way, thanks for the library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions