Home / Function/ isRefIdentifier() — vite Function Reference

isRefIdentifier() — vite Function Reference

Architecture documentation for the isRefIdentifier() function in ssrTransform.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  17df6204_81d2_952b_8111_6794dd397a83["isRefIdentifier()"]
  20c20aaf_ad5b_4014_72b5_c8262a2b5be1["ssrTransform.ts"]
  17df6204_81d2_952b_8111_6794dd397a83 -->|defined in| 20c20aaf_ad5b_4014_72b5_c8262a2b5be1
  1f4d9016_899e_0522_098a_8c1386655467["walk()"]
  1f4d9016_899e_0522_098a_8c1386655467 -->|calls| 17df6204_81d2_952b_8111_6794dd397a83
  31cff562_ac44_b48d_c084_7531a8d9bad5["isFunction()"]
  17df6204_81d2_952b_8111_6794dd397a83 -->|calls| 31cff562_ac44_b48d_c084_7531a8d9bad5
  122f5b8d_d979_5ce0_1eb2_0fc3202bf625["isStaticPropertyKey()"]
  17df6204_81d2_952b_8111_6794dd397a83 -->|calls| 122f5b8d_d979_5ce0_1eb2_0fc3202bf625
  c9e13c92_3046_b340_998d_d0be8193e4bf["isNodeInPattern()"]
  17df6204_81d2_952b_8111_6794dd397a83 -->|calls| c9e13c92_3046_b340_998d_d0be8193e4bf
  5f4200f5_1cdf_b284_eca0_1eecbd7bc4d3["isInDestructuringAssignment()"]
  17df6204_81d2_952b_8111_6794dd397a83 -->|calls| 5f4200f5_1cdf_b284_eca0_1eecbd7bc4d3
  style 17df6204_81d2_952b_8111_6794dd397a83 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/ssr/ssrTransform.ts lines 670–739

function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
  // declaration id
  if (
    parent.type === 'CatchClause' ||
    ((parent.type === 'VariableDeclarator' ||
      parent.type === 'ClassDeclaration') &&
      parent.id === id)
  ) {
    return false
  }

  if (isFunction(parent)) {
    // function declaration/expression id
    if ((parent as any).id === id) {
      return false
    }
    // params list
    if (parent.params.includes(id)) {
      return false
    }
  }

  // class method name
  if (parent.type === 'MethodDefinition' && !parent.computed) {
    return false
  }

  // property key
  if (isStaticPropertyKey(id, parent)) {
    return false
  }

  // object destructuring pattern
  if (isNodeInPattern(parent) && parent.value === id) {
    return false
  }

  // non-assignment array destructuring pattern
  if (
    parent.type === 'ArrayPattern' &&
    !isInDestructuringAssignment(parent, parentStack)
  ) {
    return false
  }

  // member expression property
  if (
    parent.type === 'MemberExpression' &&
    parent.property === id &&
    !parent.computed
  ) {
    return false
  }

  // export { id } from "lib"
  // export * as id from "lib"
  if (
    parent.type === 'ExportSpecifier' ||
    parent.type === 'ExportAllDeclaration'
  ) {
    return false
  }

  // is a special keyword but parsed as identifier
  if (id.name === 'arguments') {
    return false
  }

  return true
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does isRefIdentifier() do?
isRefIdentifier() is a function in the vite codebase, defined in packages/vite/src/node/ssr/ssrTransform.ts.
Where is isRefIdentifier() defined?
isRefIdentifier() is defined in packages/vite/src/node/ssr/ssrTransform.ts at line 670.
What does isRefIdentifier() call?
isRefIdentifier() calls 4 function(s): isFunction, isInDestructuringAssignment, isNodeInPattern, isStaticPropertyKey.
What calls isRefIdentifier()?
isRefIdentifier() is called by 1 function(s): walk.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free