code: function checkForLoop (target, firstPassRefs, step) {
    const deps = findDependencies(target, firstPassRefs)
  
    const root = step[0]
    if (deps.has(root)) {
      throw new Error(`Circular dependency in ${root}: ${step.join('->')}`)
    }
  
    for (const dep of deps) {
      checkForLoop(dep, firstPassRefs, [...step, dep])
    }
  }
docs: checkForLoops