Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ieedan committed Nov 15, 2024
1 parent fa0fbf4 commit 8dc6382
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tricky-dragons-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-svelte": patch
---

ensure circular dependencies in built registry are handled correctly.
6 changes: 5 additions & 1 deletion packages/cli/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ export async function resolveTree({
tree.push(entry);

if (includeRegDeps && entry.registryDependencies) {
// prevent circular dependencies resulting in stack overflows
const deps = new Set(entry.registryDependencies);
if (deps.has(name)) deps.delete(name);

const dependencies = await resolveTree({
index,
names: entry.registryDependencies,
names: Array.from(deps),
config,
});
tree.push(...dependencies);
Expand Down
3 changes: 3 additions & 0 deletions sites/docs/scripts/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ async function buildUIRegistry(componentPath: string, componentName: string, sty
deps.registryDependencies.forEach((dep) => registryDependencies.add(dep));
}

// cannot depend on itself
if (registryDependencies.has(componentName)) registryDependencies.delete(componentName);

return {
style,
type,
Expand Down

0 comments on commit 8dc6382

Please sign in to comment.