1.4.2 • Published 6 months ago

luacompact v1.4.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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 -g

After 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 init

Building 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 -watch

Loading 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 core

Importing 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.

KeyDescriptionInputTypeRequired
mainThe program entry point.A directory to a lua file.stringtrue
preludeCode that runs after imports are defined but before modules are defined.A directory to a lua file.string or string[]false
excludeFiles that aren't included in the final output.A list of directories.string[]false
exportDirectoryThe place to export the final output.A directory.string"build"

Contributing

Information about contributing to the project can be found here.

1.4.2

6 months ago

1.4.0

9 months ago

1.3.1

3 years ago

1.3.0

3 years ago