Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/public-shirts-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: ensure correct dependency graph extraction order and yarn berry \_dependencies support
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ export class NpmNodeModulesCollector extends NodeModulesCollector<NpmDependency,
// After initialization, if there are libraries with the same name+version later, they will not be searched recursively again
// This will prevents infinite loops when circular dependencies are encountered.
this.productionGraph[dependencyId] = { dependencies: [] }
const productionDeps = Object.entries(resolvedDeps || {})
.filter(([packageName]) => this.isProdDependency(packageName, tree))
.map(async ([, dependency]) => {
const childDependencyId = this.packageVersionString(dependency)
await this.extractProductionDependencyGraph(dependency, childDependencyId)
return childDependencyId
})

const collectedDependencies: string[] = []
for (const dep of productionDeps) {
collectedDependencies.push(await dep)
if (resolvedDeps && Object.keys(resolvedDeps).length > 0) {
for (const packageName in resolvedDeps) {
if (!this.isProdDependency(packageName, tree)) {
continue
}
const dependency = resolvedDeps[packageName]
const childDependencyId = this.packageVersionString(dependency)
await this.extractProductionDependencyGraph(dependency, childDependencyId)
collectedDependencies.push(childDependencyId)
}
}
this.productionGraph[dependencyId] = { dependencies: collectedDependencies }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class YarnBerryNodeModulesCollector extends NpmNodeModulesCollector {
}

protected isProdDependency(packageName: string, tree: NpmDependency): boolean {
return tree.dependencies?.[packageName] != null || tree.optionalDependencies?.[packageName] != null
return tree._dependencies?.[packageName] != null || tree.dependencies?.[packageName] != null || tree.optionalDependencies?.[packageName] != null
}

private async detectYarnSetup(rootDir: string): Promise<YarnSetupInfo> {
Expand Down
Loading