Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • X
  • BlueSky
  • GitHub
  • Forum
Language Manual
Overview
  • Introduction
  • Installation
  • Editor Plugins
  • Migrate to ReScript Syntax
  • Try
Language Features
  • Overview
  • Let Binding
  • Type
  • Primitive Types
  • Tuple
  • Record
  • Object
  • Variant
  • Null, Undefined and Option
  • Array & List
  • Function
  • If-Else & Loops
  • Pipe
  • Pattern Matching / Destructuring
  • Mutation
  • JSX
  • Exception
  • Lazy Values
  • Promise
  • Module
  • Import & Export
  • Reserved Keyword
JavaScript Interop
  • Embed Raw JavaScript
  • Shared Data Types
  • External (Bind to Any JS Library)
  • Bind to JS Object
  • Bind to JS Function
  • Import from / Export to JS
  • Bind to Global JS Values
  • JSON
  • Use Illegal Identifier Names
  • Generate Converters & Helpers
  • Browser Support & Polyfills
  • Interop Cheatsheet
Build System
  • Build System Overview
    • Artifacts Cleaning
    • Editor Support
    • Design Decisions
  • Build System Configuration
  • Interop with JS Build Systems
  • Build Performance
Guides
  • Converting from JS
  • Libraries
Extra
  • Newcomer Examples
  • Project Structure
  • FAQ
Docs / Language Manual / Build System Overview
Edit

You are currently looking at the v6.0 - v8.2 docs (Reason v3.6 syntax edition). You can find the latest manual page here.

(These docs are equivalent to the old BuckleScript docs before the ReScript rebrand)

Build System Overview

ReScript comes with a build system, bsb, that's meant to be fast, lean and used as the authoritative build system of the community.

Bsb provides a few templates to quickly start a new project:

SH
bsb -init my-directory-name

Feel free to inspect the various files in the newly generated directory. To see all the templates available, do:

SH
bsb -themes

The build description file is called bsconfig.json. Every ReScript project needs one.

To build a project, run:

SH
bsb -make-world

Add -w to keep the built-in watcher running. Any new file change will be picked up and the build will re-run.

Note: third-party libraries (in node_modules) aren't watched, as doing so may exceed the node.js watcher count limit. If you're doing quick and dirty modifications inside node_modules, you have to do bsb -clean-world -make-world to rebuild them.

Note 3: If you are developing across multiple devices, you may find the -ws configuration useful in order to have live-reloading across the network. Possible configurations are:

  • bsb -make-world -w -ws _ (default)

  • bsb -make-world -w -ws 0.0.0.0:9999

  • bsb -make-world -w -ws 5000

To build only yourself, use bsb -make.

bsb -help to see all the available options.

Artifacts Cleaning

If you ever get into a stable build for edge-case reasons, use:

SH
bsb -clean-world

Or bsb -clean to clean only your own artifacts.

Editor Support

Bsb generates a .merlin file, used by various editor plugins under the hood to power e.g. autocomplete, type hint, diagnosis, etc.

Tips & Tricks

A typical problem with traditional build systems is that they're not resilient against the user moving/deleting source files. Most don't clean up the old artifacts correctly after such user action*. Bsb is unfortunately no different, unless you turn on "suffix": ".bs.js" in bsconfig.json, in which case we can track which JS artifact belongs to which source file correctly, even against source file moving/deletion.

Design Decisions

* One such build system that tracks these correctly & efficiently is Tup. See the (rather accessible!) paper here. Unfortunately, Tup's implementation uses FUSE and other systems, which we can't safely use on every platform.

Interop CheatsheetBuild System Configuration

© 2024 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on