fix: compile error on analyzing exported function

This commit is contained in:
dpiercey 2025-07-10 08:16:04 -07:00 committed by Dylan Piercey
parent 59d0100319
commit 74332ef7fe
2 changed files with 11 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"@marko/runtime-tags": patch
---
Fix issue reading trying to get the root function from a exported function.

View File

@ -31,8 +31,6 @@ export function getFnRoot(path: t.NodePath<t.Node>) {
| t.NodePath<
t.FunctionExpression | t.ArrowFunctionExpression | t.ObjectMember
>;
if (curPath.isProgram()) return;
while (!isMarko(curPath)) {
if (isFunction(curPath)) {
fnPath = curPath;
@ -45,7 +43,12 @@ export function getFnRoot(path: t.NodePath<t.Node>) {
}
}
curPath = (curPath as t.NodePath<t.Node>).parentPath!;
const parentPath = curPath.parentPath;
if (parentPath) {
curPath = parentPath;
} else {
break;
}
}
return fnPath;