diff --git a/lume.lua b/lume.lua index 61ab0c2..c3cf660 100644 --- a/lume.lua +++ b/lume.lua @@ -266,12 +266,13 @@ function lume.hotswap(modname) if type(v) == "table" then update(old[k], v) else old[k] = v end end end - local oldmod = pcall(require, modname) or nil local err = nil local function onerror(e) for k, v in pairs(_G) do _G[k] = oldglobal[k] end err = lume.trim(e) end + local ok, oldmod = pcall(require, modname) + oldmod = ok and oldmod or nil xpcall(function() package.loaded[modname] = nil local newmod = require(modname)