Skip to main content

ModulesOnRails

ModulesOnRails.lua V1.1.0

Modules On Rails is a ModuleScript loader that allows you to load modules from a list of ancestors from just their name. It is a replcement for the traditional require() function. This module is intended to be utilized with VSCode, RobloxLSP, and a VSCode linting plugin.

ModulesOnRails has a method called GenerateImporter that takes a list of ancestors and an optional config table. It will return a function that can be used to import modules that are descendants of the list of ancestors. The modules availible can be filtered by setting various values in the config table. The current supported systems are:

USAGE: Below is some example code that shows how to utilize ModulesOnRails to generate an Importer module. The Second Block of code shows how to use the Importer module.

Import.lua

return ModulesOnRails.GenerateImporter({
	game:GetService("ReplicatedStorage").SharedModules;
	game:GetService("ServerScriptService").ServerModules;
})
local Import = require(game:GetService("ReplicatedStorage").Import)

local MyModule = Import("MyModule")
local Promise = Import("Promise")
local BuildingService = Import("BuildingService")

-- Once imported, any module can be used to same as if it was required.
MyModule.DoThing()
Show raw api
{
    "functions": [],
    "properties": [],
    "types": [],
    "name": "ModulesOnRails",
    "desc": "[ModulesOnRails.lua]\nV1.1.0\n\nModules On Rails is a ModuleScript loader that allows you to load modules from a list of ancestors from just their name.\nIt is a replcement for the traditional require() function. This module is intended to be utilized with VSCode, RobloxLSP,\nand a VSCode linting plugin.\n\nModulesOnRails has a method called GenerateImporter that takes a list of ancestors and an optional config table.\nIt will return a function that can be used to import modules that are descendants of the list of ancestors.\nThe modules availible can be filtered by setting various values in the config table. The current supported systems are:\n\n\nUSAGE:\nBelow is some example code that shows how to utilize ModulesOnRails to generate an Importer module.\nThe Second Block of code shows how to use the Importer module.\n\nImport.lua\n```lua\nreturn ModulesOnRails.GenerateImporter({\n\tgame:GetService(\"ReplicatedStorage\").SharedModules;\n\tgame:GetService(\"ServerScriptService\").ServerModules;\n})\n```\n\n```lua\nlocal Import = require(game:GetService(\"ReplicatedStorage\").Import)\n\nlocal MyModule = Import(\"MyModule\")\nlocal Promise = Import(\"Promise\")\nlocal BuildingService = Import(\"BuildingService\")\n\n-- Once imported, any module can be used to same as if it was required.\nMyModule.DoThing()\n```",
    "source": {
        "line": 41,
        "path": "src/modulesonrails/src/Shared/ModulesOnRails.lua"
    }
}