Git Product home page Git Product logo

fengari-loader's Introduction

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.

fengari-loader's People

Contributors

daurnimator avatar nwsw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fengari-loader's Issues

fengari-loader build

Do you have fengari-loader build like for fengari-web? I'm completely frontend developer and don't use Node.js, npm and so on.
I need to use require in lua. So I'd like to download some js file to start using fengari-loader in browser.

Support Lua style requires

Having support for requires similar to what standard Lua uses would be nice. I have an implementation that works well enough for my purposes here. This allows requires to be in the form of "fu.bar" to which is similar to "./fu/bar.lua" with how the loader currently works. It isn't doesn't work exactly like Lua's package loader, but is a starting point that can be improved if this is something fengari-loader is going to support.

Clashes across directories

Webpack's module resolution uses a relative require, while lua's does not.
The current code stores the module to be run under a package.preload key equal to the require string. If the require string is relative, then this is not unique.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.