Skip to content

npm package for browser #22

@cburgmer

Description

@cburgmer

I am in the process of moving all dependencies from bower to npm (a good read is http://dontkry.com/posts/code/browserify-and-the-universal-module-definition.html). Now I would like to depend on imagediff through npm for browser-facing code.

The npm package for imagediff however depends on canvas which itself has a dependency (cairo) that needs manual installation. For browser-facing code this dependency is not needed and this manual installation step is a deal breaker.

It would be super helpful if we could provide a npm package without that strictly required dependency. I see two options here:

  1. Publish a second package to npm just for the use in browsers, say imagediff-browser.
  2. Make the dependency on canvas optional (via optionalDependencies, https://npmjs.org/doc/json.html#optionalDependencies).

Any more that I missed?

Personally I would prefer option 2. This would be as simple as changing "dependencies" in package.json to "optionalDependencies". npm will still try to install canvas, but will skip if installation fails and return successfully.

The issue with step 2 is that NodeJS users will yield a working dependency installation while the setup is not complete. One way of mitigating that would be to throw an error indicating the unmet dependency.

What do you think?

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