revert: fix(loader): add auto loaded module to package.loaded early to prevent require loops

This reverts commit 18d1c1b47e.
This commit is contained in:
Folke Lemaitre 2024-07-21 17:32:12 +02:00
parent 8bef0742a2
commit a692bf8688
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 7 additions and 8 deletions

View File

@ -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