luau
luau copied to clipboard
Customizable source path resolution
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.
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
requirewe 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.
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