How do you guys make public module?

Hello developers,

I’m sorry if the title is hard to understand; I’ll give you an example:

I think most people make public module by requiring that by Asset ID.

Not:

require(Path.To.Module)

But:

require(12345)

And when using it by path:

local Module = require(Path.To.Module)
Module.Function() -- Autocorrect works

But when using it by Asset ID:

local Module = require(12345)
Module.Function() -- Autocorrect not works

I know it can be solved by:

local Module = require(12345) :: {
	Function: () -> ()
}
Module.Function() -- Autocorrect works

But the problem is that I can’t make it shows tips like:

-- Do function
local function Function()
	-- Something
end

Function() -- It shows 'Do function'

And I can’t replace it:

local Module = require(12345) :: {
	-- Do Function
	Function: () -> ()
}
Module.Function() -- It shows nothing.

I think the solution is making the documention for it, but I don’t think it’s efficient.

Any helps would be appreciated!

Require-by-ID is generally not recommended by Roblox as far as I know. They do not want dynamic code dependencies, as that can lead to backdoors and unexpected breakage. They’ve gone so far as deprecating features like LinkedSource. Usually, it’s preferred to have people just download and insert your module into their game. That way, autocomplete works automatically, and require’ing the module is less bulky because the developer does not need to define it’s type manually.

Terrible idea.
Just use packages instead.

1 Like

I don’t think you can publicly distribute Packages unfortunately, although that would definitely be the best option if it were possible.

But if I don’t want to reveal my source code?

no current way to do this on roblox iirc

if they can use it, they have access to the code one way or another

if you rlly don’t want ppl to see a source code then u shouldn’t make it public in the first place cuz if u want to release it for others then codes are publicly available to be readen, it’s called open source!

also with auto-complete you just showed there, required by ID doesn’t show because it’s in the cloud that isn’t in the game (they dont get type checked) but could still run whereas imported ones are shown cuz it’s there and it knows what’s inside

There’s no way to make a private module that can be required because that’s pretty much a security risk for any developer using it. If you don’t want your source code being revealed then you shouldn’t be making a public module to begin with.

Okay, I guess I was being a bit contradictory. Thanks to everyone who helped!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.