module Kernel

def load(path, wrap = false)

def load(path, wrap = false)
  if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path, try_extensions: false))
    load_without_bootsnap(resolved, wrap)
  else
    load_without_bootsnap(path, wrap)
  end
end

def require(path)

def require(path)
  return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path)
  if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path))
    return require_with_bootsnap_lfi(path, resolved)
  end
  raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(path))
rescue LoadError => e
  e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
  raise(e)
rescue Bootsnap::LoadPathCache::ReturnFalse
  false
rescue Bootsnap::LoadPathCache::FallbackScan
  fallback = true
ensure
  if fallback
    require_with_bootsnap_lfi(path)
  end
end

def require_relative(path)

def require_relative(path)
  location = caller_locations(1..1).first
  realpath = Bootsnap::LoadPathCache.realpath_cache.call(
    location.absolute_path || location.path, path
  )
  require(realpath)
end

def require_with_bootsnap_lfi(path, resolved = nil)

Note that require registers to $LOADED_FEATURES while load does not.
def require_with_bootsnap_lfi(path, resolved = nil)
  Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
    require_without_bootsnap(resolved || path)
  end
end