Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

peerDeps? #1

Closed
jlongster opened this issue Jul 30, 2014 · 7 comments
Closed

peerDeps? #1

jlongster opened this issue Jul 30, 2014 · 7 comments

Comments

@jlongster
Copy link

Should this use a peer dependency on regenerator instance of a normal dep? This makes it so that if I need to require regenerator, I have to do require('gulp-regenerator/node_modules/regenerator'), and generally makes it hard to work with other stuff. Plugins should usually use peer deps. What do you think?

@sindresorhus
Copy link
Owner

Nah, peerDeps is a mess. It's also most likely being removed eventually: npm/npm#5080

This makes it so that if I need to require regenerator, I have to do require('gulp-regenerator/node_modules/regenerator')

Have regenerator as a direct dependency if you need it: require('regenerator')

@jlongster
Copy link
Author

peerDeps has undesirable edge cases, but until npm has a better way to support plugins, I think it's good enough. Lots of other plugins use it fine. It would be a bigger problem to install regenerator as a direct dependency, as I now have two versions, and both could be wildly different versions!

I'm open to options other than peerDeps, like not even listing the dependency, but I don't see how it's not far worse to have 2 different versions installed.

@sindresorhus
Copy link
Owner

Why do you need this? What's the use-case for needing this plugin and require the same version of regenerator directly?

@jlongster
Copy link
Author

It's core to how regenerator works: it has runtime that I need to import in node. I need to do var wrapGenerator = require("regenerator/runtime/min").wrapGenerator at the top of each file (automated by a build process, of course).

@sindresorhus
Copy link
Owner

So you use gulp-regenerator to transpile your Node code and then in that code require the runtime?

If so, couldn't you just use the https://github.com/sindresorhus/gulp-regenerator#optionsincluderuntime option?

@jlongster
Copy link
Author

If I did that a copy of the runtime would be prepended on every single node source file, which is not desirable at all (not to mention breaks semantics if the runtime depends on any global state).

@jlongster
Copy link
Author

Ok, it does look like the "right" way to do it is to keep this as a dependency, and after installing plugins run npm dedupe. I'll try that out from here, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants