Lua Linker (bundler) by RedTech0
added --#define to the possible instruction set
Lua Linker
this is a file that allows you to turn a project (aka many small files which have 'require' that chain to assemble the project) into one file. This concept is taken form languages like C where you have a linker as part of the compiler
instructions
include (require)
to do a "require" you simply type
--#include [relative path]
into the Lua file at any position (must be it's own line)
[relative path] here means the way to get to the file form this file
Note that the import will not be put where the comment is but above the file importing it
define
this allows you to define a variable that will be replaced with the intended value at "build time" (in the file that defines it) to do this simply add
--#define [pattern] [replacmentStr]
at any point in the file (must be it's own line)
[pattern] is the name of the "build time" variable e.g: MY_BUILD_VAR
[replacementStr] is the value you want to replace it with e.g: "this was replaced by the bundler"
--#define MY_BUILD_VAR "this was replaced by the bundler"
this example will replace any standalone mention of MY_BUILD_VAR (even if in a string) with '"this was replaced by the bundler"' during the assembling of your Lua project
output
the output is the base file given to the linker with all it's dependencies and their dependencies stitched on top.
the linker dynamically resolves where what should be and compacts the file down (removes comments not needed spaces and tabs)
warning
this does physically graft the files together so local variables with the same name may override each other in the final product
Config
you can configure a few things abt the linker in the top of the file such as:
FUTURE FEATURES


if you are wondering why this looks so haste fully made, then i have to tell you that it is because originally this was a tool i programmed for another project where had a lot of require calls for which i iterated over potential solutions to make it more robust and then settled on the idea of a C style linker (i also never planned to upload it to the public but it seems as if there aren't a lot of tools like this out there)