Home

Awesome

Build Status npm License: MIT #fengari on libera.chat

<div align="center"> <a href="https://fengari.io/"><img height="200" src="https://fengari.io/static/images/logo.png"></a> <a href="https://github.com/webpack/webpack"><img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"></a> <h1>Fengari Loader</h1> </div>

Fengari is a lua VM written in Javascript. Webpack is a piece of Javascript tooling to compile scripts and other assets together. This repository contains a webpack loader that allows you to require lua scripts when creating your web page/application.

Install

npm install fengari-loader fengari-web webpack webpack-cli --save-dev

fengari-loader requires fengari-web and webpack as peerDependency. Thus you are able to control the versions accurately.

Usage

src/mycode.lua

return {
  42
}

src/index.js

import mycode from './mycode.lua'

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.lua$/,
        use: [
          { loader: "fengari-loader" }
        ]
      }
    ]
  }
}

Options

NameTypeDefaultDescription
dependencies{Object|undefined}undefinedIf undefined, analyse the required lua file for require calls. Otherwise, manually specifies the dependencies as a map from require string to webpack module name
strip{Boolean}falseIf true, emit stripped lua bytecode instead of source

How does it work?

fengari-loader preloads lua modules into fengari-web's global state.

Additionally, fengari-loader analyses lua code for calls to the lua global require, and adds the require strings as dependencies to the current webpack module.