fix(cache): if mod is loaded already in the loader, then return that

This commit is contained in:
Folke Lemaitre 2022-12-20 16:41:11 +01:00
parent 316503f124
commit ffabe91b2d
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 10 additions and 4 deletions

View File

@ -88,6 +88,12 @@ function M.loader(modname)
local chunk, err local chunk, err
if entry and M.check_path(modname, entry.modpath) then if entry and M.check_path(modname, entry.modpath) then
local mod = package.loaded[modname]
if type(mod) == "table" then
return function()
return mod
end
end
chunk, err = M.load(modname, entry.modpath) chunk, err = M.load(modname, entry.modpath)
else else
-- find the modpath and load the module -- find the modpath and load the module

View File

@ -36,10 +36,10 @@ local M = {}
---@field pin? boolean ---@field pin? boolean
---@class LazyPlugin: LazyPluginHandlers,LazyPluginHooks,LazyPluginRef ---@class LazyPlugin: LazyPluginHandlers,LazyPluginHooks,LazyPluginRef
---@field [1] string ---@field [1] string?
---@field name string display name and name used for plugin config files ---@field name string? display name and name used for plugin config files
---@field url string ---@field url string?
---@field dir string ---@field dir string?
---@field enabled? boolean|(fun():boolean) ---@field enabled? boolean|(fun():boolean)
---@field lazy? boolean ---@field lazy? boolean
---@field dev? boolean If set, then link to the respective folder under your ~/projects ---@field dev? boolean If set, then link to the respective folder under your ~/projects