Modules
Seriously, another dependency loader for Roblox? –Somebody, probably
Modules is a simple dependency loader for the Roblox engine. It's a single ModuleScript named "Modules" which exists in ReplicatedStorage, and it is designed to replace the built-in require
function.
local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"))
local MyModule = require("MyNamespace:MyModule")
Visit the Getting Started guide to learn the basics →
Download & Install
There's several ways you can get it:
- Take the Model from Roblox.com →
- Download from the GitHub releases page →
- Advanced: build Modules from source using Rojo 0.5.x
Once available, insert the Model into your Roblox place, then move the root "Modules" ModuleScript into ReplicatedStorage.
Structure
Modules also includes some super common patterns as included ModuleScripts. Check out the structure here:
└ ReplicatedStorage
└ Modules ← This is the root ModuleScript
├ Event
├ Maid
├ StateMachine
│ └ State
└ class
Each of these can be required by simply providing its name without a namespace. For example:
local Event = require("Event")
local State = require("StateMachine.State")