esy-compiler

Install rescript-compiler/bs-platform with esy.sh

Usage no npm install needed!

<script type="module">
  import esyCompiler from 'https://cdn.skypack.dev/esy-compiler';
</script>

README

NPM version

npx esy-compiler

Hack to install latest version of the anmonteiro/bucklescript fork of the rescript-lang/rescript-compiler while its in development.

This script gets the lastest hash, inserts it into esy.json and adds esy.json to your current working directory.

You must have jq and esy installed for it to work.

Building the compiler the first time will take a while. After that, anytime you run this script, it should go fast because esy is reusing any previously built compiler.

Also, when your are building for the browser and have a package.json and esy.json, run npm install first on your package.json then esy to install the esy.json dependencies so that esy can symlink to bs-platform in node_modules.

If you see a dynamic-run error, you can try adding (using action-plugin 0.1) to the dune-project file.

(lang dune 2.8)
(using action-plugin 0.1)

Why

See the blog post.

See the anmonteiro/bucklescript/README.md reproduced below.

At the time of this writing, running npx esy-compiler will get you the last commit hash 1a00d85a:

{
  "dependencies": {
    "bs-platform": "*"
  },
  "resolutions": {
    "bs-platform": "anmonteiro/bucklescript#1a00d85a",
    "ocaml": "anmonteiro/ocaml#75f22c8"
  },
  "esy": {
    "buildsInSource": "unsafe",
    "build": [
      "ln -sfn #{bs-platform.install} node_modules/bs-platform"
    ]
  },
  "installConfig": {
    "pnp": false
  }
}

BuckleScript

OCaml -> JS compiler.

This project is a fork of the ReScript compiler with a focus on compatibility with the wider OCaml ecosystem. A small write-up with more details on the motivation behind this project can be found in this blog post.

Installation

This project is currently unreleased. Currently, the most straightforward way to use it is via Esy.

  1. Make sure you have Esy installed (npm install -g esy should cover most workflows)
  2. Use an esy.json file like the following:
{
  "dependencies": {
    "bs-platform": "*"
  },
  "resolutions": {
    "bs-platform": "anmonteiro/bucklescript#2d3d464", <- or grab the latest commit in this repo
    "ocaml": "anmonteiro/ocaml#75f22c8"
  },
  "esy": {
    "buildsInSource": "unsafe",
    "build": [
      "ln -sfn #{bs-platform.install} node_modules/bs-platform"
    ]
  },
  "installConfig": {
    "pnp": false
  }
}
  1. Reach out on the ReasonML Discord if you can't figure it out!

Contributing

See CONTRIBUTING.md.

Acknowledgments

See Credits.md.

Roadmap

Licensing

See COPYING and COPYING.LESSER

The ocaml directory contains the official OCaml compiler (version 4.06.1). Refer to its copyright and license notices for information about its licensing.

The vendor/ninja.tar.gz contains the vendored ninja. Refer to its copyright and license notices for information about its licensing.

See Credits for more details.