All Projects → rrdelaney → Reason Scripts

rrdelaney / Reason Scripts

Licence: mit
🔰 Create a ReasonML and React development environment

Programming Languages

javascript
184084 projects - #8 most used programming language
bucklescript
41 projects

Projects that are alternatives of or similar to Reason Scripts

reasonreact-starter
Minimal yet powerful ReasonReact template
Stars: ✭ 33 (-94.88%)
Mutual labels:  create-react-app, reasonml
Web
⚡️ Supercharged version of Create React App with all the bells and whistles.
Stars: ✭ 594 (-7.76%)
Mutual labels:  create-react-app
Cra Universal
🌏 Create React App companion for universal app. No eject, auto SSR, zero config, full HMR, and more (inactive project)
Stars: ✭ 419 (-34.94%)
Mutual labels:  create-react-app
Reasonablytyped
💠 Converts Flow and TypeScript definitions to Reason interfaces
Stars: ✭ 525 (-18.48%)
Mutual labels:  reasonml
Create React Library
⚡CLI for creating reusable react libraries.
Stars: ✭ 4,554 (+607.14%)
Mutual labels:  create-react-app
React Blog
react hooks + koa2 + sequelize + mysql 构建的个人博客。具备评论、通知、上传文章等等功能
Stars: ✭ 530 (-17.7%)
Mutual labels:  create-react-app
Renature
A physics-based animation library for React focused on modeling natural world forces.
Stars: ✭ 408 (-36.65%)
Mutual labels:  reasonml
React App
Create React App with server-side code support
Stars: ✭ 614 (-4.66%)
Mutual labels:  create-react-app
Reason React Hacker News
hacker news mobile app made with reason react
Stars: ✭ 591 (-8.23%)
Mutual labels:  reasonml
Brisk
✨Cross-platform set of tools for building native UIs with Reason/OCaml
Stars: ✭ 518 (-19.57%)
Mutual labels:  reasonml
Create React App Antd
Use antd in create-react-app without ejecting ✨
Stars: ✭ 494 (-23.29%)
Mutual labels:  create-react-app
React Firebase Starter
Boilerplate (seed) project for creating web apps with React.js, GraphQL.js and Relay
Stars: ✭ 4,366 (+577.95%)
Mutual labels:  create-react-app
Ram
⚛️ React Application Manager: create and run React (and other) applications – no command line or build setup required
Stars: ✭ 585 (-9.16%)
Mutual labels:  create-react-app
Youtube React
A Youtube clone built in React, Redux, Redux-saga
Stars: ✭ 421 (-34.63%)
Mutual labels:  create-react-app
Create React Library
React NPM library starter kit based on Facebook's create react app
Stars: ✭ 597 (-7.3%)
Mutual labels:  create-react-app
React Social Network
Simple React Social Network
Stars: ✭ 409 (-36.49%)
Mutual labels:  create-react-app
React Tutorial
A walkthrough of basic React concepts.
Stars: ✭ 482 (-25.16%)
Mutual labels:  create-react-app
Query Json
Faster and simpler implementation of jq in Reason Native
Stars: ✭ 530 (-17.7%)
Mutual labels:  reasonml
Reason React
Stars: ✭ 636 (-1.24%)
Mutual labels:  reasonml
Create Eth App
Create Ethereum-powered apps with one command
Stars: ✭ 597 (-7.3%)
Mutual labels:  create-react-app


Reason Scripts

  $ yarn create react-app my-app --scripts-version reason-scripts

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.

Build Status Build status

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-scripts
$ cd <app-name>
$ yarn start

Make sure to install bs-platform globally using npm instead of yarn.

Using npm

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

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

The policy of reason tooling is to support the current LTS release, so please make sure you have Node 8 or later.

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", () => {
  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

My app won't compile on a fresh install

Try running npm install in your project directory. This helps refresh missing dependencies sometimes.

If this still does not work, make sure your file path does not include any spaces.

I got a SyntaxError after `yarn start` or `npm start` Try upgrading your Node to version 8 or later.

My editor isn't autocompleting

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/docs/en/editor-plugins.html

I don't want reason-scripts to clear my terminal

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

Reason is awesome! Where can I learn more?

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].