Improve comments in linker plugin
This commit is contained in:
8
.yarn/plugins/linker.cjs
vendored
8
.yarn/plugins/linker.cjs
vendored
@@ -9,6 +9,9 @@ module.exports = {
|
|||||||
name: "linker",
|
name: "linker",
|
||||||
factory: (require) => ({
|
factory: (require) => ({
|
||||||
hooks: {
|
hooks: {
|
||||||
|
// Yarn's plugin system is very light on documentation. The best we have
|
||||||
|
// for this hook is simply the type definition in
|
||||||
|
// https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Plugin.ts
|
||||||
registerPackageExtensions: async (config, registerPackageExtension) => {
|
registerPackageExtensions: async (config, registerPackageExtension) => {
|
||||||
const { structUtils } = require("@yarnpkg/core");
|
const { structUtils } = require("@yarnpkg/core");
|
||||||
const { parseSyml } = require("@yarnpkg/parsers");
|
const { parseSyml } = require("@yarnpkg/parsers");
|
||||||
@@ -56,10 +59,11 @@ module.exports = {
|
|||||||
structUtils.parseDescriptor(`${name}@*`, true).identHash,
|
structUtils.parseDescriptor(`${name}@*`, true).identHash,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Extend our own package's dependencies with these local overrides
|
||||||
registerPackageExtension(selfDescriptor, { dependencies: overrides });
|
registerPackageExtension(selfDescriptor, { dependencies: overrides });
|
||||||
|
|
||||||
// Filter out the original dependencies from the package spec so Yarn
|
// Filter out the original dependencies from the package spec so Yarn
|
||||||
// knows to override them
|
// actually respects the overrides
|
||||||
const filterDependencies = (original) => {
|
const filterDependencies = (original) => {
|
||||||
const pkg = structUtils.copyPackage(original);
|
const pkg = structUtils.copyPackage(original);
|
||||||
pkg.dependencies = new Map(
|
pkg.dependencies = new Map(
|
||||||
@@ -70,7 +74,7 @@ module.exports = {
|
|||||||
return pkg;
|
return pkg;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Patch Yarn's own normalizePackage method with the above filter
|
// Patch Yarn's own normalizePackage method to use the above filter
|
||||||
const originalNormalizePackage = config.normalizePackage;
|
const originalNormalizePackage = config.normalizePackage;
|
||||||
config.normalizePackage = function (pkg, extensions) {
|
config.normalizePackage = function (pkg, extensions) {
|
||||||
return originalNormalizePackage.call(
|
return originalNormalizePackage.call(
|
||||||
|
|||||||
Reference in New Issue
Block a user