Skip to content

Add Lua require mode that adheres to the PUC Lua require behavior.#344

Draft
bainchild wants to merge 1 commit intoseaofvoices:mainfrom
bainchild:main
Draft

Add Lua require mode that adheres to the PUC Lua require behavior.#344
bainchild wants to merge 1 commit intoseaofvoices:mainfrom
bainchild:main

Conversation

@bainchild
Copy link
Copy Markdown

This is a new require mode that follows the lua/luajit interpreter require behavior, excluding the default search string being different and binary libraries not being included.
There is also a design choice I'd like to get counsel on before this is merged:

  • Should the resource file types (txt, json, toml, yaml) be included in the default search string?
    • This is necessary because PUC Lua requires replace .'s in the path with /, before substituting them into the search string, which means you can't have file extensions.
    • If this is chosen to be included, it will establish a priority of extensions: .luau, .lua, .txt, .json, .toml, .yaml. This could cause problems if not considered, or be considered an intentional override mechanism, given that those resource types are transcoded to lua anyway.
    • There is also the problem of a user's lua installation's LUA_PATH environment variable not providing these 4 resource extensions (as they aren't included in the default lua search path).

I am also unsure if I should be contributing the documentation to go alongside this, as I couldn't find any general standards for documentation contribution.

New require mode has no configuration other than the key `lua_path`,
followed by the environment variable `LUA_PATH`, defaulting to
`./?.luau;./?.lua;./?/init.luau;./?/init.lua`.
@jeparlefrancais
Copy link
Copy Markdown
Contributor

Hi 👋 That is all a good start! To answer your questions:

  • I would support the file extensions lua and luau for now
  • For documentation, look at site/content/docs/path-require-mode/index.md for an example
  • Related to the LUA_PATH environment variable, I think it'd be nice if that would be configurable. The require mode could have a field to read the given env variable for the ;-separated list of paths/globs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants