Skip to content

Commit 000be57

Browse files
committed
fix: revert function exit handling to properly drop components based on return statements
1 parent b4b5be7 commit 000be57

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/core/src/component/component-collector.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ export function useComponentCollector(
6767
const entry = functionEntries.at(-1);
6868
if (entry == null) return;
6969
if (!entry.isComponent) return functionEntries.pop();
70+
const rets = AST.getNestedReturnStatements(entry.node.body);
71+
for (let i = rets.length - 1; i >= 0; i--) {
72+
const ret = rets[i];
73+
if (ret == null) continue;
74+
const shouldDrop = context.sourceCode.getScope(ret).block === entry.node
75+
&& ret.argument != null
76+
&& !isJsxLike(context.sourceCode, ret.argument, hint);
77+
if (shouldDrop) {
78+
components.delete(entry.key);
79+
break;
80+
}
81+
}
7082
return functionEntries.pop();
7183
};
7284

0 commit comments

Comments
 (0)