Skip to content
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

Makee it possiblee to disable optional dependecies for a module in package.json #5375

Open
Pajn opened this issue Feb 18, 2018 · 7 comments
Open

Comments

@Pajn
Copy link

Pajn commented Feb 18, 2018

Do you want to request a feature or report a bug?
a feature

What is the current behavior?
To avoid installing optional dependencies I have to use a flag every time I run yarn. Also that flag is global so I can't ignore optional dependencies for package A but install them for package B.

What is the expected behavior?
It should be possible to specify in package.json that I never want optional dependecies for a package.
For example

"mosca": {
  "version": "^2.7.0",
  "optionalDependencies": false
}

In the future it would be nice if I could be even more granular and for example only install zmq from mosca but not leveldown or the others. However the immediate need is to just disable all of them.

@ghost ghost assigned bestander Feb 18, 2018
@ghost ghost added the triaged label Feb 18, 2018
@bestander
Copy link
Member

There is --ignore-optional flag, I just added it to docs https://yarnpkg.com/en/docs/cli/install#toc-yarn-install-ignore-engines

@Pajn
Copy link
Author

Pajn commented Feb 18, 2018

This is not the --ignore-optional flag. --ignore-optional is 1. a blanket rule and not for a specific dependency and 2. not included in the package json meaning that it must be applied every time yarn install is run.

@bestander
Copy link
Member

Ah, I see, thanks for clarification

@bestander
Copy link
Member

Got it.
IMHO I would disable optional and bundled dependencies altogether instead of adding more workarounds for them to function.

@Pajn
Copy link
Author

Pajn commented Feb 18, 2018

Some packages do need them though. For example mosca, I do not personally need any of its optional dependencies (which are native deps and do take a long time to compile) but if one used its more powerful features those would be required.

But an option in yarnrc to at least always apply that flag in a project as it otherwise must be documented to always use and can still be forgotten would be a great start.

@bestander
Copy link
Member

@Pajn, actually you can set it up via .yarnrc files per project https://yarnpkg.com/en/docs/yarnrc#toc-cli-arguments

@Pajn
Copy link
Author

Pajn commented Mar 10, 2018

Just for reference:

This can be considered a duplicate of #5251 providing basically the same feature but configured differently. I would very happy with either solution.

#4611 which is more general would also provide a solution to this issue.

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

No branches or pull requests

2 participants