diff --git a/.changeset/tasty-houses-drum.md b/.changeset/tasty-houses-drum.md new file mode 100644 index 0000000..66aa33c --- /dev/null +++ b/.changeset/tasty-houses-drum.md @@ -0,0 +1,5 @@ +--- +"app-builder-bin": patch +--- + +fix: hoist dependencies to the real parent in nodeModuleCollector diff --git a/pkg/node-modules/nodeModuleCollector.go b/pkg/node-modules/nodeModuleCollector.go index b3a4ecc..81bc1be 100644 --- a/pkg/node-modules/nodeModuleCollector.go +++ b/pkg/node-modules/nodeModuleCollector.go @@ -214,6 +214,19 @@ func (t *Collector) resolveDependency(parentNodeModuleDir string, name string) ( if realParentNodeModuleDir == "" { return nil, nil } + + // XXX consumers expect the node_modules shape or the dependency tree ? + // hoist the depends to the actual parent + if realParentNodeModuleDir != parentNodeModuleDir { + dependencyNameToDependency = t.NodeModuleDirToDependencyMap[realParentNodeModuleDir] + if dependencyNameToDependency != nil { + dependency := (*dependencyNameToDependency)[name] + if dependency != nil { + return nil, nil + } + } + } + dependencyDir := filepath.Join(realParentNodeModuleDir, name) dependency, err := readPackageJson(dependencyDir) if err != nil {