Miscellaneous tools and plugins for Yarn.
General plugin for functionality too minor to deserve its own package yet.
Setup:
-
Copy the
Packages/yarn-plugin-vtools/bundles/@yarnpkgfolder, and paste it into your project's.yarn/pluginsfolder, asyarn-plugin-vtools. -
Modify your
.yarnrc.ymlfile to contain:plugins: - .yarn/plugins/yarn-plugin-vtools/plugin-vtools.js -
Create a
YVTConfig.[js/cjs]file in your repo-root (ie. working-directory when running yarn), with aconfigexport.Example: (see source code for all options, defined using TS interfaces)
exports.config = { "dependencyOverrideGroups": [...] };
-
Add info to config:
config.dependencyOverrideGroups = [ { name: "my company's packages", // you can change the versions/protocols of direct-dependencies here overrides_forSelf: { "directDepA": "[email protected]", "directDepB": "directDepA@^1.0.0", "directDepC": "link:../../../@Modules/directDepB" }, // and for nested subdependencies here (not tested much yet) overrides_forDeps: { "directDepD": { dependencies: {"subDepA": "[email protected]"}, peerDependencies: {"subDepB": "[email protected]"}, 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.