Skip to content

fengari-lua/fengari-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Fengari Loader

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

Name Type Default Description
dependencies {Object|undefined} undefined If 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} false If 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.