Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fengari-lua/fengari-loader
Webpack loader for fengari
https://github.com/fengari-lua/fengari-loader
fengari javascript lua webpack webpack-loader
Last synced: 2 days ago
JSON representation
Webpack loader for fengari
- Host: GitHub
- URL: https://github.com/fengari-lua/fengari-loader
- Owner: fengari-lua
- License: mit
- Created: 2017-11-20T03:10:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T16:12:05.000Z (over 3 years ago)
- Last Synced: 2024-04-25T11:21:39.146Z (7 months ago)
- Topics: fengari, javascript, lua, webpack, webpack-loader
- Language: JavaScript
- Size: 176 KB
- Stars: 27
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/fengari-lua/fengari-loader.svg?branch=master)](https://travis-ci.org/fengari-lua/fengari-loader)
[![npm](https://img.shields.io/npm/v/fengari-loader.svg)](https://npmjs.com/package/fengari-loader)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![#fengari on libera.chat](https://img.shields.io/badge/chat-%23fengari-brightgreen)](https://web.libera.chat/?channels=#fengari)[Fengari](https://fengari.io/) is a lua VM written in Javascript. [Webpack](http://webpack.js.org/) is a piece of Javascript tooling to compile scripts and other assets together.
This repository contains a [webpack loader](https://webpack.js.org/concepts/#loaders) that allows you to require lua scripts when creating your web page/application.## Install
```bash
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**
```js
return {
42
}
```**src/index.js**
```js
import mycode from './mycode.lua'
```**webpack.config.js**
```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](https://www.lua.org/manual/5.3/manual.html#pdf-package.preload) lua modules into [fengari-web](https://github.com/fengari-lua/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.