Luaubundler

1.1.6 · active · verified Tue Apr 21

Luaubundler is a command-line interface (CLI) tool designed for bundling Luau code, specifically tailored for the Roblox ecosystem. It processes an input Luau file, recursively resolves `require` statements by inlining the content of required files (including support for absolute paths), and outputs a single, consolidated Luau file. Key features include code minification, automatic renaming of local and global variables to reduce file size and obfuscate code, and support for special build macros like `LBN_METADATA` for injecting metadata into the bundle. The current stable version is 1.1.6. While the project shows a consistent update cadence through bug fixes and feature additions, its development is largely driven by community feedback. A key differentiator is its specific optimization capabilities for Luau, making it well-suited for Roblox game development. The project internally leverages `luamin.js` for minification and `luaparse` for parsing Luau code.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a basic Luau project, including an entry file with a module `require` and a `LBN_METADATA` macro. It then shows how to bundle, minify, and rename local/global variables using the `luaubundler` CLI, displaying the combined and optimized output.

# Create project directory and navigate into it
mkdir my-luau-project
cd my-luau-project

# Create a main Luau file with a module import and a macro
echo 'local MyModule = require("path/to/my/module")\nprint("Hello from Luau!")\nfunction LBN_METADATA() return { version = "1.0.0", env = "development" } end' > main.luau

# Create the nested directory for the module
mkdir -p path/to/my

# Create the required module file
echo 'return { message = "This is a required module data." }' > path/to/my/module.luau

# Create the output directory for the bundled file
mkdir dist

# Run the luaubundler CLI tool with minification, local and global variable renaming
npx luaubundler -i main.luau -o dist -n bundled.luau -m -v -g

# Display the content of the generated bundled file
cat dist/bundled.luau

# Expected output in dist/bundled.luau (variable names 'a' and 'b' are examples and may vary):
# --!native
# --[[ Luaubundler v1.1.6 ]]
# --[[ LBN_METADATA:{ "version": "1.0.0", "env": "development" } ]]
# local a = {message="This is a required module data."}
# print("Hello from Luau!")
# function b() return {version="1.0.0",env="development"} end

view raw JSON →