JSPM

  • Created
  • Published
  • Downloads 48
  • Score
    100M100P100Q7430F
  • License MIT

A javascript to pico-8 lua converter

Package Exports

  • jspicl

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jspicl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jspicl

jspicl is a Javascript to PICO-8 Lua transpiler. It creates an AST out of the JavaScript code and then transpiles it down to the LUA subset of which PICO-8 supports.

Installation

npm install jspicl --save

Usage

import jspicl from "jspicl";

const javascriptCode = `...`;
const { output, polyfills } = jspicl(javascriptCode);
console.log(
  Object.values(polyfills).join("\n"),
  output
);

In order to generate a nice lua output you need to explicitly let jspicl know by passing in an options object.

const { output, polyfills } = jspicl(javascriptCode, { prettify: true });

Return value

Property Type Description
output string The transpiled javascript code
polyfills object Table of required polyfills with their corresponding lua code.

rollup-plugin-jspicl - Rollup plugin wrapper for jspicl

games - Games created with jspicl

Known limitations

ES2015+ Not all ES2015+ features are supported. Run your code through a transpiler first such as bublé or babel.
prototype chains Not supported
Array methods Not all prototype methods have been polyfilled yet.
Math.max Only supports two arguments.
AST Not all declarations, expressions and statements have been implemented. More will be added as needed.

Versioning

This project uses semantic versioning

License

MIT