A Roblox Luau lazy-library loader with built-in libraries and functions.
Loader is, at it’s finest, a Roblox Luau library loader with some sweet built-in libraries. Loader aims to replace the require function within your game. By doing so, this allows you to lazy load modules, which means you can require modules by name like require("Module")
& deep search your DataModel for that script.
local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Loader"))
You’re probably thinking, “ANOTHER library loader?” and to that I say, yes. Loader is an extremely well-packed Library Loader to require modules. The perks of using Loader are as follows; lazy-load modules, quick load cached modules, and have global enums along with built in libraries.
Lazy-loading modules is using the name of the module to deep search the game to require. This can make workflows cleaner by applying a simple require for the name. Loader will also quick-load modules that have already been required (cached) which makes the deep search extremely inexpensive after the initial search. Built-into Loader is also an enum function to create global enums on the environment. Not to mention the extremely useful libraries included in Loader, which consistent of the following; DataSync, Interface, Manager, Network, and Roblox.
Loader is not just a library loader, but also a library provider. Built into Loader lays 5 libraries which take priority in string searching for a module. The libraries provided are all created Roblox-specific use for creating games. Each library comes with a vast amount of API which makes installing minor implementations of Roblox’s API extremely easy and convenient.
Read more about what each library provides:
So you want to use Loader, congrats! You can get started on learning how to install, use, and what API is available with Loader by moving onto the next step, Getting Started. Stick around if you’re looking to use a lite variant of Loader and read up on it’s use cases below.
Impacted by long timings? Loader is too big for a small use-case? Worried about performance? Look no further, there’s a lite variant of Loader! Lighter is a light-weight version of Loader which doesn’t include a game deep search or extra libraries. Lighter aims to solve the issue of Loader being too big for systems, plugins, and sometimes games! Lighter was originally created with the intention to use it for plugin development, but has become a cornerstone module in the development of Loader.
Lighter is extremely light-weight, and you can find the download for it here.
Installing Lighter is much different from installing Loader, but close enough. There’s 2 preferred methods of installation, but if you wish to use Rojo, you totally can.
--install https://github.com/Mullets-Gavin/Loader/tree/master/lite game.ReplicatedStorage
Lighter is pretty similar to Loader in API, so you can read about it’s documentation here. There is currently no included libraries, so you do not need to read up on the library API since it will not be included.
----------------
-- Initialize --
----------------
-- recommended
local require = require(Folder:WaitForChild("Lighter"))
-- optional
local Lighter = require(Folder:WaitForChild("Lighter"))
---------------------
-- Require Example --
---------------------
local SomeModule = require("SomeModule") -- Lighter("SomeModule")
local SomeModule = require.require("SomeModule") -- Lighter.require("SomeModule")
--------------------
-- Plugin Example --
--------------------
local plugin = script:FindFirstAncestorWhichIsA("Plugin")
local require = require(plugin:FindFirstChild("Lighter",true))
local SomeModule = require("SomeModule")
plugin
├─ Main
├─ Lighter
└─ Modules
└─ SomeModule