-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[FR] a way to ignore packages #4611
Comments
I second this request, both to manage package size and also to suppress misbehaving optional packages. The Problem This optional dependency is obviously misbehaving, but we can't fix it, so instead we'd like to ignore it. We can't just use The Suggestion (For reference, see /pull/5059 for discussion of when a package is truly optional...) |
Also, could we edit the title for clarity: |
@tvald i am not sure about the title cause maybe you you want to ignore non optional packages too! |
If a non-optional package were suppressed, that would presumably break all packages which directly or transitively depend on it, including the top-level package. It would be great if you can illustrate a case where a non-optional package can be suppressed without breaking things. Otherwise, I'd prefer the smaller and safer capability to suppress only transitively optional packages. Do note that a required dependency of an optional dependency is considered optional, unless referenced elsewhere (again, transitively) as required. |
@tvald node-pre-gyp is one simple case. it comes with a lot of unecessary data for production. |
That's far more complicated, then. I'll split off a separate feature request if that's the kind of scenario you want to support with this issue. /shrug |
Another specific use case for this feature was raised in firebase/firebase-js-sdk#546 (comment) Namely, firestore is an isomorphic package that includes large platform specific dependencies. If you are using their package for a website, it would be nice to able to tell yarn that it can ignore the dependencies that aren't specific to that platform. |
Another scenario where this can help is with Node.js usage on AWS lambda. Lambda has a 50MB code limit. Many packages (including one created by our team, for example) tend to include a large dependency tree. To fit into the space limit, one would tell yarn to ignore certain packages, assuming you know what you are doing and are ignoring only dependencies that you are not using in your code. |
Another use case -
A yarn.lock file generated on a Mac will include this dependency, so when code is deployed to a CI system running ubuntu, yarn finishes with an exit code 1. It would be nice to ignore this dependency in a particular environment. |
Still not a thing? I'm having problems rn with chromedriver getting overridden while bootstrapping, and I don't want that because it breaks while trying to download the .zip (behind corp proxy). So I want to tell yarn not to touch chromedriver, so it does not override my local modifications that should make it work -_- (I mean, I read through chromedriver/install.js, and I did what it does by myself in like twenty seconds...) |
Some package have multiple function, and if I only use part of them, then some required dependencies can suppressed. (🤔 ok, I think this is rare) I'm using |
Definitely a reasonable use case that I have encountered. We also use |
Now look at my {
"name": "test",
"version": "1.0.0",
"private": true,
"license": "WTFPL",
"dependencies": {
"debug": "^3.2.6"
},
"optionalDependencies": {
"ms": "https://registry.npmjs.org/package-that-cannot-be-installed/-/package-that-cannot-be-installed-0.0.0.tgz"
},
"resolutions": {
"ms": "https://registry.npmjs.org/package-that-cannot-be-installed/-/package-that-cannot-be-installed-0.0.0.tgz"
}
} This will install |
Adding directly to @GongT's comment and since this issue is still open. I've released my own version of a similar idea but unlike the You can find it here: Implementation: {
"name": "stupid.json",
"version": "1.0.0",
"private": true,
"license": "WTFPL",
"dependencies": {
"debug": "^3.2.6"
},
"resolutions": {
"ms": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.0.2.tgz"
}
} Honestly don't ask me why. I don't know. It just bothered me that the previous one required Sidenote: it does really work. I was able to filter out |
This is also something needed for my project which is suffering from issues with scrypt.js and node 12. Would love to install https://www.npmjs.com/package/ganache-core with |
Jest doesn't need babel anymore, so I'd love to suppress the need to download that sprawling set of dependencies even before Jest is prepared to remove it as a dependency (though it wouldn't be employed, by configuration). |
I'm building a Lambda function that has a dependency that references I'm using workspaces so I have:
When I build my lambda environment, only my But since |
Also requesting this feature; it greatly helps when optional dependencies have vulnerabilities that one would like to ignore 😄 |
I have some dependencies only use in CI, some dependencies not use in CI. I think I tried |
I have some dependencies that need to be installed ONLY in a build image within a multi stage docker container. Now how can I do this since |
Following up on @heyheyhello 's idea, there is an empty-npm-package on npm, that also works: {
"resolutions": {
"package-to-replace": "npm:empty-npm-package"
}
} |
jimp: via ygo-data, feature unused coveralls: via our test harness, abandoned, to be replaced by maintained options Approach based on yarnpkg/yarn#4611
I have some private
This works perfectly with |
I fixed this by publishing empty packages to npm with the same name as my private packages. For some reason yarn wants to ensure those packages exist on the registry before it tries to install/do anything. |
there are plenty of poorly managed libraries in npm, yarn don't react to this yet, vote for this issue to bring yarn's attention to the problem and make a nice solution, e.g. |
Right now in npm or yarn it's impossible to ignore packages.
This makes it very difficult to package small
node_modules
folder.Let me explain:
In my apps i use many packages, some for which i need to keep
optionalDependencies
likenoble
. Some i dont want and which makes thenode_modules
folder a lot bigger, likelog4js
optional dependencies.The consequence of that is that i can't use
--ignore-optional
.So for example if i want, after a
yarn install --flat --prod
cleanup and removelog4js
optionalDependencies
, i simply cant! I would need to get the dependency tree for all the optional modules, make sure there are not used by anyone else, and then remove the folders manualy.The best solution, even if not perfect, would be to be able in the package.json to add "ignored" packages. Those would be ignored in
yarn install
and thus would not alter the dependency tree.I would then simply have to add all
log4js
optional dependencies in my ignored section.Would that be possible?
The text was updated successfully, but these errors were encountered: