luau icon indicating copy to clipboard operation
luau copied to clipboard

Customizable source path resolution

Open AmberGraceRblx opened this issue 4 years ago • 2 comments
trafficstars

One of my main use cases for Luau as a tool is in linting Rojo projects. Having some method of source resolution that allows compatibility with varying project structures in .luaurc or as a command line argument would be really useful, and I can't really use luau-analyze without some custom resolution for require paths.

A possible way to do this would be adding a callback to .luaurc, which should be a luau function that takes in the expression being required, and returns a string file path.

Alternatively, some way to inject game, workspace, and script as environment variables that specifically link to a source file (perhaps requiring a table that has a __tostring metamethod should require the path at that returned string?) would be helpful.

AmberGraceRblx avatar Nov 03 '21 19:11 AmberGraceRblx

Yeah both of these are on our list of future work:

  • To make it possible to work with Roblox API surface, we need to add support for type definition files you can pass to luau-analyze or specify as part of .luaurc.
  • To make it possible to resolve require we need a way to talk about require paths that is compatible between Roblox Studio and standalone Luau tools. We plan to add support for require based on string for that

Both of these are on our roadmap for next year.

zeux avatar Nov 03 '21 19:11 zeux

Require by string RFC: https://rfcs.luau-lang.org/new-require-by-string-semantics.html Some future work on require semantics with aliases is also tracked here https://github.com/luau-lang/rfcs/pull/7

zeux avatar Nov 27 '23 23:11 zeux