As a Roblox developer, it is currently too hard to efficiently manage and import multiple modules from a directory while also benefiting from autocomplete, especially when circular dependencies are involved.
If this issue is addressed, it would improve my development experience because I could automatically load all modules in a folder with a simple syntax like require("./Modules/*")
, and enjoy comprehensive autocomplete support even when modules depend on each other. This would streamline module management, reduce repetitive code, and help catch errors early during development.
Current Approach:
Developers often need to manually iterate over a folder’s contents and build a module table, which doesn’t offer autocomplete:
local modules = {}
for i, v in script.Parent.Modules:GetChildren() do
modules[v.Name] = require(v)
end
-- 'modules' table now contains all required modules, but there's no autocomplete.
Proposed Enhanced Approach with the New Feature:
With the feature added, you could load all modules with a single require statement and benefit from full autocomplete support—even when one of the required modules, in turn, requires the module that contains all the required modules:
local modules = require("./Modules/*") -- {[name]: module}
-- 'modules' table now contains all required modules with full autocomplete support.
Use Cases:
-
Automated Module Loading:
In larger projects, managing many modules manually becomes tedious and error-prone. An automatic loading mechanism (require("./Modules/*")
) would eliminate the need for boilerplate code and reduce mistakes from manual imports. -
Improved Autocomplete in Complex Dependency Graphs:
Projects with interdependent modules often face issues with current autocomplete tools, especially when there are cyclic dependencies. Enhanced autocomplete would provide better suggestions and error checking, even when modules reference each other in a cycle, thus reducing development time and improving code quality.
By implementing this feature, Roblox would empower developers with a more efficient and user-friendly module management system, ultimately accelerating development and reducing common pitfalls associated with manual module handling and cyclic dependencies.