-
Notifications
You must be signed in to change notification settings - Fork 832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using undocumented externalDependencies
instead of peerDependencies
potentially causing issues
#369
Comments
Actually no. Because of for peer dependencies there is no ability to select one of date-fns, moment or luxon. Thus anytime date-fns users will have an error of not installed moment and luxon - thats would be an obvious and might be a reason of overheading installation. About different versions of date-fns - I cant imagine fast solution, because if libs are relying on different versions of the same library - how the peerDependencies will fix your problem |
That's what I'm currently following up on here: yarnpkg/yarn#5705 The general idea is that peerDependencies make an "official" link between The libs that require the different versions will generally then have their required version of
Yea, I understand why this is an issue. This has been an issue for many when it comes to npm and peerDependencies - as seeing those warning messages for packages that you don't need installed is annoying. But until npm has given us a better option, I think putting up with the warnings might be the best option. PeerDependencies are not installed automatically as far as I know, so it shouldn't cause overhead - only annoying warning messages. |
What about publishing three versions of the library to npm, with the correct peerDependency (or actual dependency)? |
@Haroenv thats should be a lot of libs to manage) I think would be more efficient to let npm write error messages. |
@Haroenv it's harder to maintain three versions :/ What if we remove Also, what benefits has |
@cherniavskii |
@lostpebble what if you will say that you need date-fns 2 actually |
yeah, that's why I suggest to remove it ;) |
@cherniavskii thats just a place to display that lib using some another library, because we are just ignoring moment, date-fns and luxon somewho will maybe looking for information about these libs in the package.json of installed package in node_modules. |
@dmtrKovalenko that's what I've done, I've officially included it in my You can see in great detail what I'm talking about, as we've been discussing this exact problem with the yarn team over here: yarnpkg/yarn#5705 (comment) In a regular project it wouldn't cause any issues, but in monorepos it is causing issues because of the way their algorithms work to preserve space. They would only ensure So yea @cherniavskii , its not so much the issue of |
I can imagine a build process which simply edits the package.json in a new folder for each of the versions and publishes all three with the same code but different package.json#peerDependencies to three packages. That would be a lot simpler. In a later stage I guess you could put the code that handles with the different dependencies in separate files too, which would lower the overhead of it (if that's necessary / makes sense) |
I am actually aware of 3 packages - due to overhead. Using this lib should be as easy as possible. I will think about I tend to the fact that we will not do that. Only one workaround I can imagine - create your own utils and use them. But a lot of errors for each build - not really good solution. |
Another option would be to use the standard optionalDependencies field. |
@RedHatter thanks for sharing this info here, didn't know that @dmtrKovalenko I think we should use that, instead of |
…cies [#369] Move to optionalDependencies instead of externalDependencies
Moved to optional dependencies |
Environment
Steps to reproduce
date-fns@^2.0.0-alpha.7
inside my/workspace/vs-frontend
package.date-fns
, but an earlier incompatible version (webpack-cli
for example).material-ui-pickers
up to a rootnode_modules
folder, and the otherdate-fns
packages, but leaving our specific version ofdate-fns@^2.0.0-alpha.7
behind because there is no known link betweenmaterial-ui-pickers
and that specific package and version.Expected behavior
Busy getting feedback about the issue specifically relating to
material-ui-pickers
here: yarnpkg/yarn#5705Basically the expected behaviour would be that these two modules remain aligned in the same
node_modules
level.Actual behavior
Instead I now have this folder structure:
Which is problematic for
material-ui-pickers
resolving the correctdate-fns
version. And I get this error:I'm busy getting feedback, but it seems that perhaps setting this external dependency correctly as a
peerDependency
might fix it.externalDependencies
is not documented anywhere in the NPM spec, so I'm unsure why it is being used here.The text was updated successfully, but these errors were encountered: