Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Optional peer dependencies #3066

Open
ForbesLindesay opened this Issue · 13 comments

10 participants

@ForbesLindesay

It would be useful to have a way of specifying something equivalent to peerDependencies but where they are optional. As discussed in #1400

@donaldpipowitch

+1
That would be very useful for projects like a CMS.

@Raynos

:+1:

@domenic any tips on where / how to implement this feature ?

@rlidwka

I saw issues regarding peer dependencies, optional, bundled, dev, optional peer, optional dev, not to mention exotic stuff binDependencies, did I miss something?

Guys, what about declaring those properties as flags? We can use syntax like that:

{
    dependencies: {
        foo: {
             version: "1.2.3",
             dev: true,
             optional: true,
        },
    },
}

It would really reduce this keyword clutter.

@donaldpipowitch

Sounds nice. Maybe something like this would be even more flexible and future proof:

{
    dependencies: {
        foo: {
             version: "1.2.3",
             type: "peer | dev | bin | etc.",
             optional: true
        },
    },
}
@ForbesLindesay

Sadly bin dependencies are not nearly as useful as you'd think. You can't tell whether someone is going to use a module as a binary at install time.

I don't think we should change the syntax like that. It makes things very verbose and what we have works pretty well in practice. It should probably be a separate issue for discussing this though.

@zxqfox

@donaldpipowitch Better array:

type: [ 'peer', 'dev' ],
optional: true
@donaldpipowitch

Yes, indeed. This should just be pseudo code. An array would be better :)

@ronkorving

:+1: yes, npm would really benefit from allowing this

@vjpr

+1

@ronkorving

To all who are still interested in optional peer dependencies, I've released a solution to this at https://github.com/Wizcorp/codependency . In a nutshell, it allows for a "optionalPeerDependencies" field in package.json for middleware.

Features:

  • automatic semver validation.
  • instructive error reporting for your end user.
  • optionality (it won't throw errors if you don't want it to).
  • a developer-friendly environment (allows symlinking to your middleware).

I hope it can help middleware development, and I would love to get any feedback you may wish to share. Thanks!

PS: If you're still interested, I wrote a tumblr post about this.

@fixe

@othiym23 is this something that will be integrated?

@othiym23
Owner

@fixe It's not something that's on the development team's radar, so probably not anytime soon.

@jxm262

:+1: would like this as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.