Skip to content

Commit

Permalink
[INTERNAL] ui5Framework: Resolve dependencies of projects resolved vi…
Browse files Browse the repository at this point in the history
…a workspaces
  • Loading branch information
RandomByte committed Nov 15, 2022
1 parent 47c9a4e commit b811811
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/graph/helpers/ui5Framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ class ProjectProcessor {
dependencies.push(...resolvedOptionals.filter(($)=>$));
}

let projectIsFromWorkspace = false;
if (this._workspace) {
const workspaceNode = await this._workspace.getNode(depMetadata.id);
if (workspaceNode) {
log.verbose(`Resolved module ${workspaceNode.id} via workspace ${this._workspace.getName()}`);
log.verbose(`Resolved module ${workspaceNode.id} via ${this._workspace.getName()} workspace`);
depMetadata = workspaceNode;
projectIsFromWorkspace = true;
}
}

Expand All @@ -65,6 +67,29 @@ class ProjectProcessor {
dependencies.forEach((dependency) => {
projectGraph.declareDependency(libName, dependency);
});
if (projectIsFromWorkspace) {
// Add any dependencies that are only declared in the workspace resolved project
// Do not remove superfluous dependencies (might be added later though)
await Promise.all(project.getFrameworkDependencies().map(async ({name, optional, development}) => {
// Only proceed with dependencies which are not "optional" or "development",
// and not already listed in the dependencies of the original node
if (optional || development || dependencies.includes(name)) {
return;
}

if (!this._libraryMetadata[name]) {
throw new Error(
`Unable to find dependency ${name}, required by project ${project.getName()} ` +
`(resolved via ${this._workspace.getName()} workspace) in current set of libraries. ` +
`Try adding it temporarily to the root project's dependencies.`);
}

// TODO: If a cyclic dependency is declared, this will empty the event loop.
// I guess this is a general issue and not limited to projects resolved via workspaces
await this.addProjectToGraph(name, projectGraph);
projectGraph.declareDependency(libName, name);
}));
}
}
}

Expand Down

0 comments on commit b811811

Please sign in to comment.