vue-hook-optimizer 0.0.64 → 0.0.65

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -390,30 +390,45 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
390
390
  }
391
391
  return;
392
392
  }
393
- traverse2(argNode, {
394
- Identifier(path1) {
395
- const binding = path1.scope.getBinding(path1.node.name);
396
- if (graph.nodes.has(path1.node.name) && (path1.parent.type !== "MemberExpression" && path1.parent.type !== "OptionalMemberExpression" || path1.parent.object === path1.node) && (binding?.scope.block.type === "Program" || parentScope === binding?.scope)) {
397
- if (["watch", "useEffect"].includes(hookName) && watchArgs.size > 0) {
398
- const watchArgsNames = Array.from(watchArgs).map((arg) => arg.name);
399
- watchArgs.forEach((watchArg) => {
400
- if (!watchArgsNames.includes(path1.node.name)) {
401
- graph.edges.get(watchArg.name)?.add(path1.node.name);
402
- }
403
- });
404
- }
405
- const _node = nodeCollection.getNode(path1.node.name);
406
- if (_node?.info?.used) {
407
- _node?.info?.used?.add(hookName);
408
- } else if (_node) {
409
- _node.info = {
410
- ..._node?.info,
411
- used: /* @__PURE__ */ new Set([hookName])
412
- };
413
- }
393
+ if (argNode.type === "Identifier") {
394
+ const binding = patentScope.getBinding(argNode.name);
395
+ if (graph.nodes.has(argNode.name) && (binding?.scope.block.type === "Program" || parentScope === binding?.scope)) {
396
+ const _node = nodeCollection.getNode(argNode.name);
397
+ if (_node?.info?.used) {
398
+ _node?.info?.used?.add(hookName);
399
+ } else if (_node) {
400
+ _node.info = {
401
+ ..._node?.info,
402
+ used: /* @__PURE__ */ new Set([hookName])
403
+ };
414
404
  }
415
405
  }
416
- }, patentScope, node);
406
+ } else {
407
+ traverse2(argNode, {
408
+ Identifier(path1) {
409
+ const binding = path1.scope.getBinding(path1.node.name);
410
+ if (graph.nodes.has(path1.node.name) && (path1.parent.type !== "MemberExpression" && path1.parent.type !== "OptionalMemberExpression" || path1.parent.object === path1.node) && (binding?.scope.block.type === "Program" || parentScope === binding?.scope)) {
411
+ if (["watch", "useEffect"].includes(hookName) && watchArgs.size > 0) {
412
+ const watchArgsNames = Array.from(watchArgs).map((arg) => arg.name);
413
+ watchArgs.forEach((watchArg) => {
414
+ if (!watchArgsNames.includes(path1.node.name)) {
415
+ graph.edges.get(watchArg.name)?.add(path1.node.name);
416
+ }
417
+ });
418
+ }
419
+ const _node = nodeCollection.getNode(path1.node.name);
420
+ if (_node?.info?.used) {
421
+ _node?.info?.used?.add(hookName);
422
+ } else if (_node) {
423
+ _node.info = {
424
+ ..._node?.info,
425
+ used: /* @__PURE__ */ new Set([hookName])
426
+ };
427
+ }
428
+ }
429
+ }
430
+ }, patentScope, node);
431
+ }
417
432
  });
418
433
  }
419
434
  }