lua-pack is an advanced lua bundler similar to webpack made for lua 5.1+ written in js

Overview

lua-pack

lua-pack is an advanced lua bundler similar to webpack made for lua 5.1+ written in js that makes working on large scale projects easy and fast. it takes all the files in your project and packs them into a single production ready file.

usage

to define a module in your project the first line must be like the following.

_NAME = "module name here";

return { whatever = true };

to load that module in any other source file you can just call the load function

local module = load("module name here");
print(module.whatever);

initialize project

to start your project start by making a new folder which will contain all your lua files then open a terminal in that folder and run

luapack init

it will first ask for what the name of the project and then for which of the files is going to be the entry/main file and then go through all the options for you to select.

building project

you can build your project in two different ways directly building it and serving it to a webserver.

build

by running the following, it will output the build into a newly created folder inside your project folder

luapack build

serve

serving the project will allow for hot updating the build every time a script is changed and host that build on your localhost to allow easy testing of your code.

luapack serve

after running the command it will build your script and put it on the first open port it can find on your localhost, from then on every time you make a change or add a source file it will create a new build and update the site

features

lua-pack has many unique features to make your life easier.

file importing and relative paths

you can easily import any file and interact between the files in your project.

relative file paths

luapack allows you to use relative file paths when loading modules and importing files. let's say you are want to load a module name by file name in the same directory you can do something like the following.

local module = load('./module.lua') -- load file via relative path
local module2 = load('../folder/module2.lua') -- load file from up a directory

relative paths can be disabled. when relative paths are disabled file based paths are relative to the project folder instead of the current file. to disabled them change "enableRelativePaths" in your luapack.config.json file to false

importing files

all files in the project folder are automatically bundled into the project for ease of use. let's say your file structure looks like the following :

project
|-folder
| |-sample.txt
| `-test.json
`-main.lua

to load both files from inside of main.lua all you have to dos

local sampleTxt = import('./folder/sample.txt')
local testJson  = import('./folder/test.json') -- json files are automatically converted to lua tables on compilation so you can directly index them after importing

prelude

adding the "prelude" variable to your config file will put the selected file before the modules get loaded in the package.

string literal caching

if enabled, repeated use of the same string literals will cause the bundler to automatically localize them to save on storage space

print("test")
local b = "test"
local c = "test"

-- string literal caching enabled
local a = "test"
print(a)
local b = a
local c = a

instruction optimization

when enabled, any large repetition of instructions will automatically be put in a for loop in the output

print("test")
print("test")
print("test")
print("test")

-- instruction optimization enabled
for i = 1, 4 do
    print("test")
end

installation

installing pre-built release

  1. download the .zip file from the releases page
  2. unpack that .zip file to any folder on your computer
  3. add that folder to your windows PATH (tutorial)

building from source

must have node.js installed

  1. open cmd

  2. install pkg

     npm i -g pkg
  3. open the source folder

  4. install the node modules

    npm i
  5. run the build script

    npm run build
  6. add that folder to your windows PATH (tutorial)

You might also like...

WIP: Power-pack for Turbo Streams

TurboPower turbo_power is a power-pack for Turbo Streams. It provides Turbo Streams with a bunch of new actions and additionally adds the morph action

Jan 4, 2023

Simple utils to pack arrays, objects and strings to a flat object (and back again).

packrup Simple utils to pack (and unpack) arrays and strings to a flat object. Status: In Development Please report any issues 🐛 Made possible by my

Dec 23, 2022

Leader Board is a simple project based on JavaScript programing language. The purpose of this project is to work with APIs and ASYNC & AWAIT methods. I have used vanilla JavaScript with web pack to implement this project

Leader Board is a simple project based on JavaScript programing language. The purpose of this project is to work with APIs and ASYNC & AWAIT methods. I have used vanilla JavaScript with web pack to implement this project

Leader Board - JavaScript Project Table of contents Overview The challenge Screenshot Links Project Setup commands My process Built with What I learne

Oct 21, 2022

📦 🍣 Zero-config JS bundler for ESM, CommonJS, and .d.ts outputs

pkgroll Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single command! Features Zero conf

Dec 23, 2022

A template for a vanilla(no ui-framework) project with webgi engine in typescript using parcel bundler.

WebGi starter project A template for a vanilla(no ui-framework) project with webgi engine in typescript using parcel bundler. For the latest version a

Jan 3, 2023

📦 🍣 Zero-config JS bundler for ESM, CommonJS, and .d.ts outputs. (Forked from pkgroll)

📦 🍣 puild (A fork of pkgroll) Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single com

Sep 6, 2022

A demo of using the new require.context syntax in Expo with Metro bundler

Metro Context Modules Demo This is a demo of using the experimental 'Context Module' (require.context) feature in Metro bundler. Setup metro.config.js

Nov 19, 2022

A template for buildind scrollable landing pages with Gsap, ScrollTrigger and webgi engine in typescript using parcel bundler.

A template for buildind scrollable landing pages with Gsap, ScrollTrigger and webgi engine in typescript using parcel bundler.

Threejs + GSAP + WEBGi 100% Free Course This is a template used in my fast course "building scrolable pages with ScrollTrigger and Threejs" for a vani

Dec 17, 2022

This is a simple web app that allows a user add list of tasks that needs to be completed. It is built using webpack and served by a webpack dev server.

TO-DO-LIST "To-do list" is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as compl

Aug 19, 2022
Releases(v1.0.9)
Owner
Chris
you know me
Chris
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A fast, safe and easy caching mechanism similar to Redis written in typescript

Viper Viper is a memory based caching mechanism which is aimed towards ease of use and speed. It's in a very early stage right now and not meant to us

Japroz Saini 1 Jan 24, 2022
AwardBot is an open source advanced giveaway bot. Written in Discord.js

AwardBot is an open source advanced giveaway bot. Written in Discord.js. You can set conditions for the giveaways, automatically deliver the prizes, and lock the giveaways.

Award 2 Oct 29, 2022
Web-pack based Todo-List Website built using HTML, CSS and JavaScript. Tested Using Jest.

To-DO List Live Link Additional description about the project and its features: Built With HTML and CSS Javascript HTML & CSS3 & JavaScript Linters Gi

Saadat Ali 8 Mar 31, 2022
🦸‍♀️ A super template for Next.js with a pack of incredible tools

Next-Plate ??‍♀️ A super template for Next.js with a pack of incredible tools ?? Translations ?? Demo → Deploy your own copy of this template in just

Gustavo Matheus Morinaga Cardoso 80 Dec 30, 2022
Make a release for Jitsi test browser page (minify js/css files, pack the app in one file).

JitsiTestBrowserTool This tools allows you to make a release for Jitsi test browser page (minify js/css files, pack the app in one file). /!\ Not work

GIP Renater 4 Aug 15, 2022
Pack all your node_modules and other files you want inside your project to a zip file.

?? Node Modules Packer Use Cases | Usage | Examples | Headless | Benchmarks | Reference This is a library to package all your node_modules and other f

Vinicius Lourenço 14 Dec 1, 2022
Generates MIDI chords and scales, which can be downloaded as a free MIDI pack.

MIDI Chords and Scales Pack Description This projects generates (~400) MIDI chords and (~300) MIDI scales, which can be downloaded as a free MIDI pack

Simon Heimler 10 Dec 14, 2022