luacompact v1.4.2
Installation
Before installing LuaCompact, ensure that you have Node.js installed. After that, you can install LuaCompact using one of the commands below depending on which package manager you prefer.
# Using NPM
npm i luacompact -g
# Using Yarn
yarn global add luacompact
# Using PNPM
pnpm add luacompact -gAfter installation, you should be able to use LuaCompact either by using the luacompact or lcp commands in terminal.
Usage
Creating a project
Once LuaCompact is installed, you will first have to create a LuaCompact project. To create a LuaCompact project, open the directory you want the project in and run the command below.
luacompact initBuilding a project
To build a project, all you need to do is run the command below. Optionally, you can also include a -watch or -w parameter to the command to automatically have LuaCompact build the project once a file is changed.
# Building without -watch
luacompact build
# Building with -watch
luacompact build -watchLoading modules/scripts
Loading a module/script is made pretty simple.
All you need to do is use the load function and pass through a relative path to the script you want to load.
The load function supports both .lua and .luau files.
index.lua Example:
local core = load("core.lua")
core.helloWorld()core.lua Example:
local core = {}
function core.helloWorld()
print("Hello world!")
end
return coreImporting other files
Not only can you load modules, but you can also import other files using the import function.
Unlike the load function, the import function requires the file extension in the function call.
JSON files are automatically converted to Lua dictionaries, while every other file will be converted to text.
index.lua Example:
local defaultConfig = import("assets/config.json")
print(defaultConfig.Enabled)config.json Example:
{
"Enabled": true
}Config
Every LuaCompact project has a config file called luacompact.json.
Below, you can see the options and what each option is used for.
| Key | Description | Input | Type | Required |
|---|---|---|---|---|
| main | The program entry point. | A directory to a lua file. | string | true |
| prelude | Code that runs after imports are defined but before modules are defined. | A directory to a lua file. | string or string[] | false |
| exclude | Files that aren't included in the final output. | A list of directories. | string[] | false |
| exportDirectory | The place to export the final output. | A directory. | string | "build" |
Contributing
Information about contributing to the project can be found here.