@justjurt/bcc
v1.2.1
Published
Simple bundler+minifier for Computer Craft Lua projects
Readme
BCC
BCC is a command-line bundler and minifier for ComputerCraft Lua projects. It collects a project's Lua files into one runnable file, rewrites require so bundled modules are loaded from that file, and optionally shortens identifiers and removes comments and whitespace.
Requirements
- Node.js
- A Lua project with a
main.luafile at its project root
Install
Install the published CLI globally:
npm install --global @justjurt/bccOr, when working from a local clone, invoke main.js with Node. Run BCC from the Lua project directory, because input files and output paths are relative to the current working directory.
cd path/to/my-lua-project
bccFor example, from this repository's sample project:
cd _testing
node ../main.jsWhat compilation does
- Finds project files whose paths contain
.lua, excluding paths with abuilddirectory and patterns ignored by.bccignore. - Wraps each included file in a function and bundles them into
build/app.lua. - Runs
app.main(args), so the project's rootmain.luais the entry point. - Minifies
build/app.luain place unless minification is disabled.
For a one-level directory path such as data/data.lua, the bundle exposes the module as require('data.data'). Keep modules at the project root or one directory level deep; deeper paths are not reliably converted to module names by the current bundler.
Command-line arguments
| Argument | Description |
| --- | --- |
| -nm, --no-minify | Bundle the project without minifying the output. |
| -w, --watch | Compile once, then watch the current project directory and recompile after detected changes. |
| --ignore [pattern ...] | Create .bccignore if needed and append the given patterns. If no patterns are supplied, only create the file. This operation exits without compiling. |
Examples:
bcc --no-minify
bcc -w
bcc --ignore examples/ temp.lua
bcc --ignore.bccignore uses gitignore-style patterns, with paths relative to the project directory. It is read during each bundle. Patterns supplied to --ignore are appended only if they are not already present; use --ignore without patterns to create the file, then edit it to remove or change entries.
Watch mode relies on Node.js recursive filesystem watching, which may vary by operating system and filesystem. The generated build output is excluded from bundling.
Output
The compiled program is written to build/app.lua. The output directory is created automatically. If minification is enabled, the same file is replaced with its minified version.
Development
The package exposes bcc through main.js. The bundler/bundle.js and minify/minify.js modules can also be run directly with Node or required as functions. There is currently no automated test suite configured in package.json.
