{"id":50430439,"url":"https://github.com/naphiwka/onelua","last_synced_at":"2026-05-31T14:00:54.865Z","repository":{"id":351618758,"uuid":"1210644362","full_name":"napHiwka/OneLua","owner":"napHiwka","description":"Lua bundler with auto require following","archived":false,"fork":false,"pushed_at":"2026-05-30T21:00:13.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-30T22:20:57.519Z","etag":null,"topics":["build","bundle","bundler","bundling","lua","luajit"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/napHiwka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-14T16:05:41.000Z","updated_at":"2026-05-30T21:02:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/napHiwka/OneLua","commit_stats":null,"previous_names":["naphiwka/onelua"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/napHiwka/OneLua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napHiwka%2FOneLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napHiwka%2FOneLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napHiwka%2FOneLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napHiwka%2FOneLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/napHiwka","download_url":"https://codeload.github.com/napHiwka/OneLua/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/napHiwka%2FOneLua/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33733754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","bundle","bundler","bundling","lua","luajit"],"created_at":"2026-05-31T14:00:54.125Z","updated_at":"2026-05-31T14:00:54.860Z","avatar_url":"https://github.com/napHiwka.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OneLua\n\nOneLua bundles a Lua project into a single distributable `.lua` file. It can be used as a CLI tool or embedded as a library. Mostly source code requires no manual changes to be bundled.\n\n## Features\n\n- Follows `require()` dependencies automatically, depth-first.\n- Hoists `---@` annotations to the top of the bundle for language server support.\n- Aliases let you remap module names at runtime (useful for dynamic requires).\n- Optionally rewrites simple dynamic `require()` calls to static ones.\n- Optionally strips comments and produces compact output.\n- Optionally verifies the bundle by loading it immediately after writing.\n- Compatible with Lua 5.1 - 5.5, LuaJIT.\n\n## CLI\n\n```sh\nlua bundler.lua --entry source/main.lua --src ./ --out dist/bundle.lua\n```\n\nOnly `--entry` is required; everything else is optional.\n\n- `--entry \u003cmodule\u003e` entry module name or file path\n- `--src \u003cdir\u003e` source root (default: `./`)\n- `--out \u003cfile\u003e` output path (default: `./bundle.lua`)\n- `--name \u003cid\u003e` exported variable name (default: entry basename)\n- `--config \u003cfile\u003e` config file path\n- `--strip \u003cmode\u003e` strip comments (`all` or `non_ann` modes)\n- `--compact` collapse blank lines in output\n- `--resolve` rewrite resolvable dynamic requires\n- `--debug` print verbose dependency resolution logs\n- `--verify` load the bundle after writing to confirm it runs\n- `--help` show help\n\n## Config File\n\nThe bundler auto-detects `bundler.config.lua` or `bundlerConfig.lua` in the working directory. CLI flags override config values. A configuration file with detailed comments is available [here](bundler.config.lua). There is also a [bare](bare.config.lua) conf file to make it easier to customize if you are already familiar with the structure.\n\n## Concepts\n\n### Static vs dynamic requires\n\nA *static require* has a string literal argument known at analysis time:\n\n```lua\nlocal json = require(\"vendor.json\")\n```\n\nA *dynamic require* is computed at runtime and cannot be resolved statically:\n\n```lua\nlocal mod = require(prefix .. \"utils\")\n```\n\nDynamic requires will produce a `WARN:` line during bundling. To handle them, use `extra` to force-include the module and `aliases` to remap the name (see below), or use `--resolve` if the pattern is simple enough to rewrite automatically.\n\n### Resolve\n\nWhen enabled, the bundler rewrites simple dynamic require patterns to static ones before emitting. It handles two forms:\n\n```lua\n-- Before\nlocal mod = require(prefix .. \"utils\")\nlocal mod = require(\"mylib.\" .. name)\n\n-- After (example, depending on what the bundler can infer)\nlocal mod = require(\"utils\")\nlocal mod = require(\"mylib.name\")\n```\n\nOnly patterns where the dynamic part is a single identifier concatenated with a string literal are rewritten. Everything else still produces a `WARN:` and requires manual aliases.\n\n### Extra\n\nLists module names to include unconditionally, even if they are not reachable from the entry module via static requires. Useful for modules that are only loaded dynamically. By default, requires found inside extra files are followed normally. Set `skip_extra_files_requires = true` to include the extra file itself but not its dependencies.\n\n### Aliases\n\nAliases remap a module name inside the bundle at runtime. The bundle's `require()` wrapper consults the alias table before looking up a loader, so `require(\"old.name\")` transparently resolves to whatever `\"new.name\"` was bundled as.\n\n```lua\naliases = {\n    [\"json\"] = \"vendor.json\", -- require(\"json\") -\u003e vendor.json\n    [\".namespace\"] = \"src.namespace\", -- require(\".namespace\") -\u003e src.namespace\n    [\"namespace\"] = \"src.namespace\", -- require(\"namespace\") -\u003e src.namespace\n}\n```\n\nThe primary use case is dynamic requires: if a module calls `require(base .. \"utils\")`, the runtime will produce a string like `\"utils\"` or `\".utils\"` depending on `base`. Adding aliases for both spellings pointing to the bundled module name (`\"src.utils\"`) means the call resolves correctly without modifying the source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaphiwka%2Fonelua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaphiwka%2Fonelua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaphiwka%2Fonelua/lists"}