npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reason-relay-scripts

v0.6.11-2

Published

Scripts for Create React App with ReasonML and Relay.

Downloads

6

Readme

Reason Scripts provides a JS-like development environment for developing web apps with the Reason programming language and React. It bootstraps an environment to automatically compile all Reason code to JS, provide features like reloading and bundling, and seamlessly use JS code from Reason.

Getting Started

Using Yarn

Note that using yarn create requires Yarn 0.25 or later

To create a new app using Reason and React, run:

$ npm install -g bs-platform
$ yarn create react-app <app-name> -- --scripts-version reason-relay-scripts
$ cd <app-name>
$ yarn start

Using npm

$ npm install -g bs-platform create-react-app
$ create-react-app <app-name> --scripts-version reason-relay-scripts
$ cd <app-name>
$ npm start

Directory Layout

Creating a new app makes an <app-name> directory with the following layout:

<app-name>/
  README.md
  node_modules/
  package.json
  bsconfig.json
  .gitignore
  public/
    favicon.ico
    index.html
  src/
    index.re
    index.css
    app.re
    app.css
    logo.svg

Features

Everything from Create React App

  • Highly-optimized build configuration
  • Pre-configured test runner
  • Friendly developer environment
  • "eject" Webpack config
  • Environment variable configuration
  • Automatic PWA configuration
  • Low configuration builds

Reason Entrypoint

The entry point to the app is src/index.re. From the start your new app will be based on Reason, but can seamlessly interop with existing JS files and projects!

Automatic Compilation of Reason/Ocaml files

Any Reason/Ocaml file will be automatically compiled to a JS file. For example, a file called math_fns.re can be required by a JS file:

import { add } from './math_fns.re'

const sum = add(1, 4)

Jest Integration

Reason Scripts will automatically configure a Jest environment to test Reason code. Any code found in a file ending with _test.re, _test.ml or test.js will be considered a test and run with Jest. From these files, the normal Jest API can be used interacting with any other modules defined in your app. For example:

/* math_fns.re */

let add x y => x + y;
/* math_fns_test.re */

open Jest;

test "addition" (fun () => {
  let num_1 = 10;
  let num_2 = 12;

  expect (Math_fns.add num_1 num_2) |> toBe 22;
});

Or if you prefer writing your tests in JavaScript, just don't forget to import the tested module:

/* maths_fns.test.js */

import Math_fns from './math_fns.re'

test('addition', () => {
  const num1 = 10
  const num2 = 12

  expect(Math_fns.add(num1, num2)).toBe(22)
})

For more documentation on the Jest API, see bs-jest

Importing non-Reason files

You can require CSS files with:

[%bs.raw {|require('./App.css')|}];

or any other kind of file (like SVG's) with:

let logo : string = [%bs.raw {|require('./logo.svg')|}];

Help, Tips, and Tricks

Editor support is provided by Merlin. To generate a .merlin file, run the app with npm start or yarn start.

See our full editor integration guide here: https://reasonml.github.io/guide/editor-tools/editors-plugins

Use FORCE_COLOR=true react-scripts start | cat - as your start command instead

Checkout our fancy website: https://reasonml.github.io/!

We also have a very active Discord to come talk about Reason, and ask for help: https://discordapp.com/invite/reasonml