Skip to content

Commit

Permalink
feat: avoid meaningless circular dependency in watch
Browse files Browse the repository at this point in the history
  • Loading branch information
zcf0508 committed Mar 13, 2024
1 parent 6577f3f commit 93c0b20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/analyze/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export function analyze(
traverse(path1.node.value, {
MemberExpression(path2) {
if (path2.node.object.type === 'ThisExpression' && path2.node.property.type === 'Identifier') {
if (watchArg) {
if (watchArg && watchArg.name !== path2.node.property.name) {
graph.edges.get(watchArg.name)?.add(path2.node.property.name);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/analyze/setupScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,11 @@ export function processSetup(
|| parentScope === binding?.scope)
) {
if (['watch', 'useEffect'].includes(hookName) && watchArgs.size > 0) {
const watchArgsNames = Array.from(watchArgs).map(arg => arg.name);
watchArgs.forEach((watchArg) => {
graph.edges.get(watchArg.name)?.add(path1.node.name);
if (!watchArgsNames.includes(path1.node.name)) {
graph.edges.get(watchArg.name)?.add(path1.node.name);
}
});
}
const _node = nodeCollection.getNode(path1.node.name);
Expand Down

0 comments on commit 93c0b20

Please sign in to comment.