From a692bf86883457f45fe3f773bfc8bc4d9e4b070c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 21 Jul 2024 17:32:12 +0200 Subject: [PATCH] revert: fix(loader): add auto loaded module to package.loaded early to prevent require loops This reverts commit 18d1c1b47e175cd58dc12bf4792ef4e9a50505fa. --- lua/lazy/core/loader.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index ac53690..c5cdca2 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 - local mod = package.loaded[modname] - if type(mod) ~= "table" then - mod = loadfile(ret.modpath, nil, nil, ret.stat)() - end - package.loaded[modname] = mod M.auto_load(modname, ret.modpath) - -- selene: allow(incorrect_standard_library_use) - return function() - return mod + local mod = package.loaded[modname] + if type(mod) == "table" then + return function() + return mod + end end + -- selene: allow(incorrect_standard_library_use) + return loadfile(ret.modpath, nil, nil, ret.stat) end end