darklua icon indicating copy to clipboard operation
darklua copied to clipboard

respect .luaurc files from other folders

Open ghost opened this issue 9 months ago • 6 comments

Today I ran into a problem while working with Darklua. I have a package that has its own .luaurc file, there is also a .luaurc file in the root folder of my project. Since Darklua doesn't respect other .luaurc files, obviously it failed to bundle my code. I tested similar case with regular luau and everything ran fine. Darklua should check other folders for .luaurc files and treat requires accordingly.

ghost avatar Feb 12 '25 22:02 ghost

Hi! What do you mean by other luaurc files? Right now darklua reads the nearest luaurc to each file it processes. So it'll use the aliases from the nearest config file it can find.

jeparlefrancais avatar Feb 13 '25 14:02 jeparlefrancais

When I run darklua, it reads only the first .luaurc it encounters and uses the aliases from that file for every other .luau file, ignoring any other .luaurc file. Since I have multiple .luaurc files, darklua just fails to bundle code from different folder which contain other luaurc files.

I can provide a simple project which shows the problem if needed.

ghost avatar Feb 13 '25 15:02 ghost

Behavior Regarding .luaurc Files

As requested on Discord, here is additional information on how .luaurc files function. This is drawn from the Luau RFCs repository

Alias Maps in .luaurc

Alias maps are defined in .luaurc, which uses a JSON-like syntax. For example:

{
  "aliases": {
    "alias1": "/path/of/alias1",
    "alias2": "/path/of/alias2"
  }
}

Inheritance of Missing Aliases

Any aliases not specified in a child directory’s .luaurc are inherited from the alias maps of its parent directories. You can override any specific fields in the child .luaurc if necessary.

Relative Paths

If an alias points to a relative path, that path is resolved relative to the .luaurc file in which the alias is defined.


You can already experiment with this feature in Visual Studio Code, since the Luau LSP extension has implemented alias maps.

mskfox avatar Mar 02 '25 23:03 mskfox

The problem is that darklua doesn't use .luaurc files from parent directories. It only uses the file from the root directory of the project.

ghost avatar Mar 03 '25 08:03 ghost

The problem is that darklua doesn't use .luaurc files from parent directories. It only uses the file from the root directory of the project.

I use darklua, and from what I've observed, darklua looks for the .luaurc file in the closest directory to the script. So if there's a .luaurc in a directory closer than the root, it will presumably override the global settings.

So, what you're saying doesn't seem to be correct.

mskfox avatar Mar 03 '25 18:03 mskfox

I'm not saying that this is intended behavior. I'm on Windows and when I bundle my code Darklua simply doesn't use more than one .luaurc file.

ghost avatar Mar 03 '25 21:03 ghost