@@ -114,7 +114,7 @@ function M.check_loaded(modname)
114
114
end
115
115
116
116
--- @param modname string
117
- --- @return any
117
+ --- @return fun ()| string
118
118
function M .loader (modname )
119
119
modname = modname :gsub (" /" , " ." )
120
120
local entry = M .cache [modname ]
@@ -139,7 +139,7 @@ function M.loader(modname)
139
139
end
140
140
end
141
141
end
142
- return chunk or ( err and error ( err )) or " not found in lazy cache "
142
+ return chunk or err or ( " module " .. modname .. " not found " )
143
143
end
144
144
145
145
--- @param modpath string
@@ -197,8 +197,12 @@ function M.load(modkey, modpath)
197
197
end
198
198
199
199
function M .require (modname )
200
+ local chunk = M .loader (modname )
201
+ if type (chunk ) == " string" then
202
+ error (chunk )
203
+ end
200
204
--- @diagnostic disable-next-line : no-unknown
201
- local mod = M . loader ( modname ) ()
205
+ local mod = chunk ()
202
206
--- @diagnostic disable-next-line : no-unknown
203
207
package.loaded [modname ] = mod
204
208
return mod
@@ -216,10 +220,10 @@ function M._index(path)
216
220
M .indexed [path ] = true
217
221
Util .ls (path .. " /lua" , function (_ , name , t )
218
222
local topname
219
- if t == " directory" then
220
- topname = name
221
- elseif name :sub (- 4 ) == " .lua" then
223
+ if name :sub (- 4 ) == " .lua" then
222
224
topname = name :sub (1 , - 5 )
225
+ elseif t == " link" or t == " directory" then
226
+ topname = name
223
227
end
224
228
if topname then
225
229
M .topmods [topname ] = M .topmods [topname ] or {}
0 commit comments