so I have two files, A.lua and B.lua:
A.lua:
Code: Select all
local A = {}
-- manage circular dependencies
local _pkgname = ...
package.loaded['__' .. script.mod_name .. '__/' .. _pkgname:gsub('%.', '/') .. '.lua'] = A
-- manage circular dependencies
local B = require('some.thing.B')
Code: Select all
local B = {}
-- manage circular dependencies
local _pkgname = ...
package.loaded['__' .. script.mod_name .. '__/' .. _pkgname:gsub('%.', '/') .. '.lua'] = B
-- manage circular dependencies
local A = require('some.thing.A')
But it is ugly. Is there really no better way to create the loaded key than doing this dance:
Code: Select all
local _pkgname = ...
package.loaded['__' .. script.mod_name .. '__/' .. _pkgname:gsub('%.', '/') .. '.lua'] = ... the main table of the file ...