MCPcopy Index your code
hub / github.com/adobe/react-spectrum / enforceNoCircularDependencies

Function enforceNoCircularDependencies

yarn.config.cjs:92–124  ·  view source on GitHub ↗

@param {Context} context

({Yarn})

Source from the content-addressed store, hash-verified

90
91/** @param {Context} context */
92function enforceNoCircularDependencies({Yarn}) {
93 // enforce that there are no circular dependencies between our packages
94 function addDep(workspace, seen = new Set()) {
95 if (seen.has(workspace.ident)) {
96 let arr = [...seen];
97 let index = arr.indexOf(workspace.ident);
98 // ok for pkg to depend on itself
99 if (arr.slice(index).length > 1) {
100 // better to error the constraints early for this for a more meaningful error message
101 throw new Error(
102 `Circular dependency detected: ${arr.slice(index).join(' -> ')} -> ${workspace.ident}`
103 );
104 } else {
105 return;
106 }
107 }
108
109 seen.add(workspace.ident);
110
111 for (let d of Yarn.dependencies({ident: workspace.ident})) {
112 if (d.type === 'peerDependencies') {
113 continue;
114 }
115 addDep(d.workspace, seen);
116 }
117
118 seen.delete(workspace.ident);
119 }
120
121 for (const workspace of Yarn.workspaces()) {
122 addDep(workspace);
123 }
124}
125
126/** @param {Dependency} dependency */
127function isOurPackage(dependency) {

Callers 1

yarn.config.cjsFile · 0.85

Calls 1

addDepFunction · 0.85

Tested by

no test coverage detected