Darklua is getting a new rule "convert_require" that is able to generate Roblox style requires from file system path requires. The cool thing: it can work with and without a Rojo sourcemap š
Without a Rojo sourcemap
When no sourcemap is provided, darklua will assume that your file system is laying out the files in the same way Roblox. Darklua will assume everything is relative:
going up a directory means going up a parent
getting a file in a directory means indexing a child instance
init.lua (or init.luau) files turn their directory into an ModuleScript instance, which is what darklua will target when you require a folder (note: this can be configured to something else like index.lua or index.luau as preferred)
With a Rojo sourcemap
If your setup is more complicated that described before (which I expect is not uncommon), you can provide a sourcemap file in the configuration file. This lets darklua find all your source files no matter where they are in the DataModel and generate the appropriate Instance paths.
[x] add entry to the changelog
[x] add tests for generating requires from Rojo sourcemaps in a DataModel
Closes #31
Darklua is getting a new rule
"convert_require"
that is able to generate Roblox style requires from file system path requires. The cool thing: it can work with and without a Rojo sourcemap šWithout a Rojo sourcemap
When no sourcemap is provided, darklua will assume that your file system is laying out the files in the same way Roblox. Darklua will assume everything is relative:
init.lua
(orinit.luau
) files turn their directory into an ModuleScript instance, which is what darklua will target when you require a folder (note: this can be configured to something else likeindex.lua
orindex.luau
as preferred)With a Rojo sourcemap
If your setup is more complicated that described before (which I expect is not uncommon), you can provide a sourcemap file in the configuration file. This lets darklua find all your source files no matter where they are in the DataModel and generate the appropriate Instance paths.