diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index ac53690f..c5cdca22 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -552,16 +552,15 @@ function M.loader(modname) end if ret then + M.auto_load(modname, ret.modpath) local mod = package.loaded[modname] - if type(mod) ~= "table" then - mod = loadfile(ret.modpath, nil, nil, ret.stat)() + if type(mod) == "table" then + return function() + return mod + end end - package.loaded[modname] = mod - M.auto_load(modname, ret.modpath) -- selene: allow(incorrect_standard_library_use) - return function() - return mod - end + return loadfile(ret.modpath, nil, nil, ret.stat) end end