Skip to content

Commit ba260a8

Browse files
committed
[FIX] projectGraphBuilder: Add module cache invalidation
If a visited module did not resolve to any specification (project or extensions), try recreating the module when visiting it again from a different parent. Resolves UI5/cli#807 This is an alternative to #611 This change might have a greater impact on performance since er might recreate modules that are not relevant to UI5 Tooling more than once if they are listed multiple times in the dependency tree. Before this change, such modules where only visited once.
1 parent 9278d76 commit ba260a8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/graph/projectGraphBuilder.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ async function projectGraphBuilder(nodeProvider, workspace) {
161161
const {nodes, parentProject} = queue.shift(); // Get and remove first entry from queue
162162
const res = await Promise.all(nodes.map(async (node) => {
163163
let ui5Module = moduleCollection[node.id];
164+
165+
if (ui5Module) {
166+
log.silly(
167+
`Re-visiting module ${node.id} as a dependency of ${parentProject.getName()}`);
168+
169+
const {project, extensions} = await ui5Module.getSpecifications();
170+
if (!project && !extensions.length) {
171+
// Invalidate cache if the cached module is visited through another parent project and did not
172+
// resolve to anything useful (project or extension(s)) before.
173+
// The module being visited now might be a different version where it contains UI5 Tooling
174+
// configuration, or one of the parent projects could have defined a shim extension meanwhile
175+
log.silly(
176+
`Cached module ${node.id} did not resolve to any projects or extensions. ` +
177+
`Recreating module as a dependency of ${parentProject.getName()}...`);
178+
ui5Module = null;
179+
}
180+
}
181+
164182
if (!ui5Module) {
165183
log.silly(`Visiting Module ${node.id} as a dependency of ${parentProject.getName()}`);
166184
log.verbose(`Creating module ${node.id}...`);
@@ -174,8 +192,6 @@ async function projectGraphBuilder(nodeProvider, workspace) {
174192
shimCollection
175193
});
176194
} else {
177-
log.silly(
178-
`Re-visiting module ${node.id} as a dependency of ${parentProject.getName()}`);
179195
if (ui5Module.getPath() !== node.path) {
180196
log.verbose(
181197
`Warning - Dependency ${node.id} is available at multiple paths:` +

0 commit comments

Comments
 (0)