{"id":19493687,"url":"https://github.com/kristian/yarn-plugin-optional-resolution","last_synced_at":"2025-10-14T17:49:23.235Z","repository":{"id":148342252,"uuid":"477116260","full_name":"kristian/yarn-plugin-optional-resolution","owner":"kristian","description":"Yarn 2+ / Berry plugin adding support for resolving non-existing optional package dependencies / version ranges","archived":false,"fork":false,"pushed_at":"2023-11-14T17:24:39.000Z","size":2458,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T18:05:48.820Z","etag":null,"topics":["yarn","yarn-berry","yarn-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kristian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T16:53:52.000Z","updated_at":"2025-04-09T18:08:16.000Z","dependencies_parsed_at":"2024-11-10T21:27:58.158Z","dependency_job_id":"26c56482-cd71-4dc5-b536-66feef0aabe7","html_url":"https://github.com/kristian/yarn-plugin-optional-resolution","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kristian/yarn-plugin-optional-resolution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristian%2Fyarn-plugin-optional-resolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristian%2Fyarn-plugin-optional-resolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristian%2Fyarn-plugin-optional-resolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristian%2Fyarn-plugin-optional-resolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristian","download_url":"https://codeload.github.com/kristian/yarn-plugin-optional-resolution/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristian%2Fyarn-plugin-optional-resolution/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020051,"owners_count":26086807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["yarn","yarn-berry","yarn-plugin"],"created_at":"2024-11-10T21:26:58.214Z","updated_at":"2025-10-14T17:49:23.219Z","avatar_url":"https://github.com/kristian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@yarnpkg/plugin-optional-resolution`\n\nYarn Berry plugin that adds support for non-existing optional package dependencies. Without this plugin Yarn 2+ (\"Berry\") installing or adding an optional package which does not exist in the package repository will result in an error:\n\n```\n➤ YN0027: \u003cpkg\u003e@unknown can't be resolved to a satisfying range\n➤ YN0035: The remote server failed to provide the requested resource\n➤ YN0035:   Response Code: 404 (Not Found)\n➤ YN0035:   Request Method: GET\n➤ YN0035:   Request URL: https://registry.yarnpkg.com/\u003cpkg\u003e\n```\n\nThis plugin changes this behavior in two ways:\n\n  1. If an optional package requested from any defined NPM package registry (see [`npmRegistryServer`](https://yarnpkg.com/configuration/yarnrc#npmRegistryServer) and [`npmScopes`](https://yarnpkg.com/configuration/yarnrc#npmScopes)), would lead to a 404 (Not Found) error, this package instead, serves Yarn a \"fake\" / dummy package metadata file, leading to an [`optional-pkg`](https://www.npmjs.com/package/optional-pkg) instead, which satisfies the requested version range.\n\n  2. Before packing, this plugin will \"realize\" all those optional, but non-existent, packages, by removing them from the `\"optionalDependencies\"` section before publishing. This allows others to consume the package, without requiring the optional resolution plugin, or even with other package managers like NPM.\n\nThis makes `\"optionalDependencies\"` truly optional, in a sense that they do not even need to exist, which behaves according to the [NPM package specification](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#optionaldependencies). Sometimes you favour a behavior like this, especially if you are working e.g. with multiple private package registries, that may, or may not contain certain package artifacts.\n\n\u003e ⚠️ There is a limitation for projects with *multiple workspaces* at the moment: As this plugin hooks into the network requests towards the NPM package registry and the hooking mechanism doesn't provide information for which workspace the request was made, this plugin assumes a package is optional, if it is mentioned in any `\"optionalDependencies\"` section of any of the workspace packages. Meaning that even if the package does not exist, installation would not fail for some workspaces, even if they declare the package as a hard dependency in their `\"dependencies\"` or `\"devDependencies\"` section.\n\n## Installation\n\nYou can add this plugin to your Yarn 2+ (\"Berry\") project running the following command:\n\n```bash\nyarn plugin import https://raw.githubusercontent.com/kristian/yarn-plugin-optional-resolution/v1.2.0/bundles/%40yarnpkg/plugin-optional-resolution.js\n```\n\n## Author\n\nWritten by [Kristian Kraljić](https://kra.lc/).\n\n## Found a Bug?\n\nPlease file any issues [on Github](https://github.com/kristian/yarn-plugin-optional-resolution).\n\n## License\n\nThis package is licensed under the [MIT](LICENSE) license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristian%2Fyarn-plugin-optional-resolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristian%2Fyarn-plugin-optional-resolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristian%2Fyarn-plugin-optional-resolution/lists"}