inconsistent `require` behavior when files imported by other mods

When a file is imported using "__modname__.path.to.file", the behaviour of "require" within that file changes (vs a "normal" require).
Based on my observations:

If the file is in the root of the mod directory, relative imports do not work at all.
If the file is in a folder, relative imports are searched for in the folder rather than the root of the mod directory. E.g. inside "mod1/folder/foo.lua", a require("bar") tries to look for "__mod1__/folder/bar.lua". whereas normally it would search for "__mod1__/bar.lua"

This seems like very weird behaviour.

If this is intentional, this could be added to documentation
If this is not intentional... I guess this is a bug report.
Statistics: Posted by GlassBricks — Sun Nov 14, 2021 1:15 am