function inspectForImports(
    ast,
    moduleRecord,
    packageName,
    isBuiltin,
    includeDebugInfo
  ) {
    // get all requested names that resolve to isBuiltin
    const namesForBuiltins = entries(moduleRecord.importMap)
      .filter(([, resolvedName]) => isBuiltin(resolvedName))
      .map(([requestedName]) => requestedName)
    const esmModuleBuiltins = inspectEsmImports(ast, namesForBuiltins)
    const { cjsImports: cjsModuleBuiltins } = inspectImports(
      ast,
      namesForBuiltins
    )
    if (cjsModuleBuiltins.length + esmModuleBuiltins.length === 0) {
      return
    }
    // add debug info
    if (includeDebugInfo) {
      const moduleDebug = debugInfo[moduleRecord.specifier]
      moduleDebug.builtin = [
        ...new Set([...esmModuleBuiltins, ...cjsModuleBuiltins]),
      ]
    }
    // aggregate package builtins
    if (!packageToBuiltinImports.has(packageName)) {
      packageToBuiltinImports.set(packageName, [])
    }
    let packageBuiltins = packageToBuiltinImports.get(packageName) ?? []
    packageBuiltins = [
      ...new Set([
        ...packageBuiltins,
        ...cjsModuleBuiltins,
        ...esmModuleBuiltins,
      ]),
    ]
    packageToBuiltinImports.set(packageName, packageBuiltins)
  }
@param {AST} ast
@param {import('./moduleRecord').LavamoatModuleRecord} moduleRecord
@param {string} packageName
@param {(value: string) => boolean} isBuiltin
@param {boolean} includeDebugInfo
@returns