local loaded = {}
table.insert(package.loaders, 1, function(mod_name)
local mod_root = string.match(mod_name, '^[^./]+')
if mod_root and package.loaded[mod_name] == nil and not loaded[mod_name] then
loaded[mod_name] = true
local pkgids = require '_rsplug/on_lua'.luam2pkgid[mod_root] or {}
for _, id in ipairs(pkgids) do
require '_rsplug'.packadd(id)
end
end
if package.loaded[mod_name] ~= nil then
local m = package.loaded[mod_name]
return function()
return m
end
end
return nil
end)