Miscellaneous tools and plugins for Yarn.
General plugin for functionality too minor to deserve its own package yet.
Setup:
-
Copy the
Packages/yarn-vtools-plugin/Dist
folder, and paste it into your project's.yarn/plugins
folder, asyarn-vtools-plugin
. -
Modify your
.yarnrc.yml
file to contain:plugins: - .yarn/plugins/yarn-vtools-plugin/index.js
-
Create a
YVTConfig.[js/cjs/mjs]
file in your repo-root (ie. working-directory when running yarn), with aconfig
export.Example: (see source code for all options, defined using TS interfaces)
exports.config = { "dependencyOverrideGroups": [...] };
-
Add info to config:
config.dependencyOverrideGroups = [ { // you can change the versions/protocols of direct-dependencies here overrides_forSelf: { "directDepA": "directDepA@1.0.0", "directDepB": "directDepA@^1.0.0", "directDepC": "link:../../../@Modules/directDepB" }, // and for nested subdependencies here (not tested much yet) overrides_forDeps: { "directDepD": { dependencies: {"subDepA": "subDepA@1.0.0"}, peerDependencies: {"subDepB": "subDepB@1.0.0"}, peerDependenciesMeta: {"subDepB": {"optional": true}} } } }, // conditional overrides also work; just use javascript/nodejs conditionals like usual process.env.MYPROJECT_USER == "bob" && { overrides_forSelf: { "depA": `link:../../bob's/path/to/depA` } }, process.env.MYPROJECT_USER == "alice" && { overrides_forSelf: { "depA": `link:/alice's/path/to/depA` } } ];
-
Profit. Future yarn-installs will run the config-getter script, read the list of overrides, overwrite its in-memory descriptors (ie. protocol, version, etc.) with those found in the overrides list, and then proceed with using those descriptors to install your project's dependencies.