I think the concept you are trying to use is called Private Modules. It was a feature where developers could publish modules that were private but named MainModule
and they could be required by scripts. This practice was used by developers who wanted to keep their modules closed-source. Approximately a year ago, they were removed. You can read about this in this official DevForum post. I believe @EmeraldSlash had a post discussing the update.
There are a few ways to keep people from taking your modules, but I personally wouldn’t recommend them.
The first one would be obfuscation. This is when you make a code really obscure and illegible to the point where the reader has no clue what’s going on with the code.
Another way would be to run the bytecode, either by storing it somewhere in the loader or importing it from a third-party API when wanting to compile it.