Require should take strings

As a Roblox developer, it is currently too hard to build a Luau package that works both within Roblox and Luau generally, this is because unlike the entirety of Luau tooling externally, Roblox forces us to use the script.Parent.Module syntax.

If we’re writing code directly for Roblox, this isn’t an issue (and is pretty user friendly actually). The issue is when I’m trying to write tests externally for said project. Roblox doesn’t provide us with roblox-cli, so we have to come up with hacky solutions like this to convert the script system to a relative path system:

local function dir(directory: string)
	return setmetatable({} :: { [string]: any },
	{ __index = function(_, path) return directory .. path end })
end

local script = dir ""
script.Parent = dir "./"

return script

And this is at the top of every script that uses require:

if not script then script = require("./RelativeString") end

Instead, if Roblox allowed us to require the same way we require from Lune or any other external tool, we wouldn’t need this hacky script to get string paths from a script parameter.

If Roblox is able to address this issue, it would improve my development experience because I wouldn’t need a hacky module to require modules externally.

2 Likes

For reference, I’m not asking that Roblox removes the current system of requiring modules, as I stated, this is very user friendly.

Instead, I’m asking that require additionally can take a relative path and convert it to script.Parent.Module and so on

For example:

  • ./Module1script.Parent.Module
  • ../Module1script.Parent.Parent.Module

and so on

oh wait this was in an approved RFC uhh
lets forget i posted this

3 Likes