This standard aims to bridge the gaps between different Luau and Lua environments. By following this standard, Luau packages can be published on npm
.
Additionally, darklua can be used to transform module imports into environment specific imports, but also Luau code into Lua code.
- Define a
package.json
(npm documentation). - Use the
@pkg
alias to import dependent packages. This means that to import a package namedmypackage
, write the import statement asrequire(“@pkg/mypackage”)
.
- Use the global variable
LUA_ENV
to branch for different environments. - Put
luau
in the packagekeywords
entry. - For Roblox developers: avoid publishing Rojo configuration files (
*.project.json
files) into the package itself. Usenpm pack --dry-run
oryarn pack --dry-run
to verify if the package will contain these files.
Developers can define a global variable named LUA_ENV
so that Luau packages can be used for different Luau (and even Lua) environments.
The next table shows the pair of environments and values recognized by the standard. If an environment you would like to support is not defined here, open an issue to submit it.
Environment | Value |
---|---|
Roblox | roblox |
Lune | lune |
For Luau users, the quickest way to setup a full project with the latest tooling is with generator-luau. It will create the necessary configuration files to analyse, auto-format, bundle to a single file, build a Roblox model, run tests with jest and automate releases.