Examples

Let’s compile LuaRocks!

  1. Clone the source-code:

    > git clone --depth 1 https://github.com/luarocks/luarocks
    > cd luarocks
    
  2. Compile it into ./luarocks (or luarocks.exe on Windows)

    # lrc can compile Teal!
    > lrc src/bin/luarocks -o luarocks.exe -mluarocks.** --xpath teal:src/?? -P "vendor/??;src/??" \
          --xpath "teal:types/?.d.tl;src/?.d.tl"
    

Compile lrc with itself

  1. Clone the source-code:

    > git clone https://codeberg.org/lrocket/lrc
    > cd lrc
    
  2. Compile!

    > lrc cmd/lrc.lua -o lrc.exe
    

Compile a Website (WebAssembly)

  1. Fetch WebAssembly support:

    > luarocks install lrocket-build-wasm
    
  2. Create a new file called website.lua with the following contents:

    -- website.lua
    document.innerHTML = '<button>Click me!</button>'
    
    local button = document.querySelector 'button'
    button.addEventListener('click', function()
        alert('Lua function called!')
    end)
    
  3. Compile to standalone HTML:

    > lrc website.lua --otype wasm-html -o website.html