vue-hook-optimizer 0.0.53 → 0.0.54

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -202,6 +202,7 @@ function getComment(node) {
202
202
 
203
203
  // src/analyze/setupScript.ts
204
204
  var traverse2 = import_traverse2.default.default?.default || import_traverse2.default.default || import_traverse2.default;
205
+ var ignoreFunctionsName = ["defineProps", "defineEmits", "withDefaults"];
205
206
  function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
206
207
  const spread = _spread || [];
207
208
  const nodeCollection = new NodeCollection(_lineOffset);
@@ -218,7 +219,7 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
218
219
  if (element?.type === "Identifier") {
219
220
  const name = element.name;
220
221
  const binding = path.scope.getBinding(name);
221
- if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration.init?.callee.name))) {
222
+ if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ignoreFunctionsName.includes(declaration.init?.callee.name))) {
222
223
  graph.nodes.add(name);
223
224
  nodeCollection.addNode(name, element, {
224
225
  comment: getComment(path.node)
@@ -231,7 +232,7 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
231
232
  if (element?.type === "RestElement" && element.argument.type === "Identifier") {
232
233
  const name = element.argument.name;
233
234
  const binding = path.scope.getBinding(name);
234
- if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration.init?.callee.name))) {
235
+ if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ignoreFunctionsName.includes(declaration.init?.callee.name))) {
235
236
  graph.nodes.add(name);
236
237
  nodeCollection.addNode(name, element.argument, {
237
238
  comment: getComment(path.node)
@@ -248,7 +249,7 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
248
249
  if (property.type === "ObjectProperty" && property.value.type === "Identifier") {
249
250
  const name = property.value.name;
250
251
  const binding = path.scope.getBinding(name);
251
- if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration.init?.callee.name))) {
252
+ if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ignoreFunctionsName.includes(declaration.init?.callee.name))) {
252
253
  graph.nodes.add(name);
253
254
  nodeCollection.addNode(name, property.value, {
254
255
  comment: getComment(property)
@@ -261,7 +262,7 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
261
262
  if (property.type === "RestElement" && property.argument.type === "Identifier") {
262
263
  const name = property.argument.name;
263
264
  const binding = path.scope.getBinding(name);
264
- if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration.init?.callee.name))) {
265
+ if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ignoreFunctionsName.includes(declaration.init?.callee.name))) {
265
266
  graph.nodes.add(name);
266
267
  nodeCollection.addNode(name, property.argument, {
267
268
  comment: getComment(property)
@@ -276,7 +277,7 @@ function processSetup(ast, parentScope, parentPath, _spread, _lineOffset = 0) {
276
277
  if (declaration.id?.type === "Identifier") {
277
278
  const name = declaration.id.name;
278
279
  const binding = path.scope.getBinding(name);
279
- if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration.init?.callee.name))) {
280
+ if (binding && (path.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path.parent) && !(declaration.init?.type === "CallExpression" && declaration.init?.callee.type === "Identifier" && ignoreFunctionsName.includes(declaration.init?.callee.name))) {
280
281
  graph.nodes.add(name);
281
282
  nodeCollection.addNode(name, declaration, {
282
283
  comment: getComment(path.node)