We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0cab1b9 commit 4f13e25Copy full SHA for 4f13e25
plugins/std/src/shared/require.lua
@@ -1,13 +1,21 @@
1
local unpack = unpack
2
-local includeCache = {}
+
3
+---@type table<lightuserdata, table<string, table | true>>
4
+local cache = {}
5
6
function Autorun.require(path)
- if includeCache[path] then
- return unpack(includeCache[path])
7
+ cache[Autorun.PLUGIN] = cache[Autorun.PLUGIN] or {}
8
+ local localCache = cache[Autorun.PLUGIN]
9
10
+ if localCache[path] == true then
11
+ error("Circular dependency detected for path: " .. path)
12
+ elseif localCache[path] then
13
+ return unpack(cache[path])
14
end
15
16
+ localCache[path] = true
17
local outputs = { Autorun.include(path) }
- includeCache[path] = outputs
18
+ localCache[path] = outputs
19
20
return unpack(outputs)
21
0 commit comments