Could we have a ModuleStorage service?

An entire additional line of code to call a dependency? Blasphemy.
Would you rather that I inject it into every script with getfenv and make my scripts illegible to static analysis tools?

I’m not vigorously against this feature request, but we’re talking about one line at most. It’s not a big enough deal to warrant an extension of require IMO.

1)
Not sure I dig the idea of this service. We already have 2 types of storages. One that replicates and one that’s server-only. These work fine for storing your modulescripts.

2)
It was suggested that we could use a ‘/’ to traverse this service. This is essentially what we already do though.

require(rs.EnemyLogic.LogicA)
vs
require("EnemyLogic/LogicA")

Those are essentially the same, except one is used everywhere in RBXLua and the other is never seen.

3)
It was suggested that this would be useful if you could recursively search for a modulescript by name and not have to path to it. But we can literally already do this with findFirstChild.

require(rs:findFirstChild("MyModuleScript",true))

In summary: I think these suggestions are all way too niche and nothing suggested can’t already be done with almost the identical amount of code.

1 Like

I can’t speak for use cases in normal development, but when making plugins my code ends up looking like this:

Script1:

local pluginScript = script.Parent.Parent
local Object = require(pluginScript.Object)
Object.new("Test")

Script2:

local pluginScript = script.Parent.Parent.Parent.Parent
local Object = require(pluginScript.Object)
Object.new("Test2")

Maybe I misunderstood OP’s suggestion, but I interpreted it in a way that I’d be able to:

  • Define a module storage that could be used in any script
  • Reference that in any script regardless of where it was parented, enabling me to do:
local Object = require("pluginModules/Object") --or "pluginModules.Object"
Object.new("Test")

, saving me from being dependent on parent hierarchy, because right now if I change where a module is parented it and all of its descendants break.

I think OP meant an actual service, like ReplicatedStorage, which require() will search in.
(although having ModuleScriptService:SetStorage("myPlugin12345",plugin) would be nice)

In that case it’s useless to me