Skip to content

Optional groups of npm dependencies #2

@gilmoreorless

Description

@gilmoreorless

Open Question

See this wiki page for an explanation.

Background Details

I'm contributing to a project that's using package.json to install a heap of build-time dependencies, using the devDependencies section (i.e. it doesn't need to be published on npm).

What I want to do is effectively add a separate, optional build configuration that will build for a different target. This new build config would need an additional set of npm dependencies, but I don't want to add them to devDependencies as they wouldn't be needed by the majority of the people on the project.

I looked into the optionalDependencies option for package.json, but that doesn't do what I want. It will always try to install them, but not chuck a wobbly if they fail. Whereas I want a separate group of dependencies which are all required for the group, but to make the group itself an optional install.

Options

These are my current options as I see them:

  1. Add the extra dependencies to devDependencies or optionalDependencies and be done with it. If people don't like the extra bloat, too bad.
  2. Make the extra build config effectively a "sub-package" by putting a separate package.json in a subdirectory. This feels dirty.
  3. Use something like squirrel and write some glue code.
  4. Throw my hands in the air, say "ah fuck it, I dunno, I'll ask someone else" and post an open question on GitHub.

I went with option 4, but doesn't help in the long term. Thoughts?

(cc @DamonOehlman who I know will be interested)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions