Run & Build

The plugin integrates with the ReScript compiler to provide build functionality directly within the IDE. It automatically detects the rescript CLI from your project’s node_modules/.bin/ directory and supports all standard compiler commands.

Run Configurations

Native

Create and manage ReScript build configurations from RunEdit Configurations+ReScript.

Available Commands

Command

CLI Arguments

Description

Build

rescript build

One-shot compilation of the entire project

Build (Watch)

rescript build -w

Continuous compilation with file watching

Clean

rescript clean

Remove all compiled artifacts

Build

The Build command performs a one-shot compilation of your ReScript project. The compiler processes all .res and .resi source files and generates JavaScript output in the lib/ folder (typically lib/js/ or lib/es6/, depending on your rescript.json configuration).

  • Compiles all source files that have changed since the last build

  • Output is written to the lib/ directory, mirroring your src/ folder structure

  • If compilation fails, error messages with file paths, line numbers, and column numbers appear in the Run panel

  • The process exits with a non-zero status code on errors, which the IDE displays as a failed run

Example output structure after a successful build:

my-project/
├── src/
│   ├── App.res
│   └── Utils.res
└── lib/
    └── js/
        └── src/
            ├── App.bs.js
            └── Utils.bs.js

Build (Watch)

The Build (Watch) command starts the compiler in watch mode, which monitors your source files for changes and automatically recompiles them.

  • The compiler stays running as a long-lived process, watching the filesystem for changes

  • When you save a .res or .resi file, the compiler performs an incremental recompilation of only the affected files and their dependents

  • Build status notifications are sent via LSP to update the status bar indicator in real time

  • To stop the watch process, click the Stop button (red square) in the Run panel, or press Ctrl+F2

  • Watch mode is ideal for active development, as it provides near-instant feedback on code changes

Tip

You can keep a Build (Watch) run configuration running alongside your editor session. Compilation errors will appear both in the Run panel console and as LSP diagnostics (red underlines) in the editor.

Clean

The Clean command removes all compiled artifacts generated by the ReScript compiler.

  • Deletes the lib/ directory and all generated .js files within it

  • Also removes .ast, .cmt, .cmti, and other intermediate build artifacts

  • Use this when you encounter stale build artifacts, unexplained compilation errors, or after changing rescript.json configuration

  • After cleaning, you need to run a full Build to regenerate all output files

Configuration Options

  • Working directory – The project root (where rescript.json is located). The plugin uses this path to locate the rescript CLI and as the working directory for the compiler process.

  • Command – Build, Build (Watch), or Clean.

  • Additional arguments – Extra CLI flags passed to the rescript command (e.g., --verbose).

CLI Detection

The plugin automatically locates the rescript CLI binary by searching in the following order:

  1. <working directory>/node_modules/.bin/rescript

  2. <project root>/node_modules/.bin/rescript

  3. Parent directories of the project root (for monorepo setups where dependencies are hoisted)

If the CLI is not found, the run configuration displays an error: “Cannot find ‘rescript’ CLI. Ensure it is installed via npm in the project.”

Run configurations let you build, watch, and clean your ReScript project without leaving the IDE, keeping your terminal free and your build workflow integrated with the editor.

Gutter Run Icons

Native

A green Run icon appears in the gutter (left margin) of .res files, providing a quick way to start a build without creating a run configuration manually.

Where Icons Appear

The run icon is placed at the first top-level declaration in the file. Only let, type, and module declarations at the top level are eligible. The icon appears on the keyword token (let, type, or module) of the first such declaration.

For example, in this file the icon appears on line 1 next to let:

let greeting = "Hello"  // <-- Run icon appears here

let add = (a, b) => a + b

type user = {name: string, age: int}

Prerequisites

The gutter icon only appears when the project contains a rescript.json file in the project root. This ensures the icon is not shown for non-ReScript projects or standalone .res files outside a valid ReScript project.

Click Behavior

Clicking the gutter icon opens the standard IntelliJ run menu, allowing you to:

  • Run – Execute the default ReScript build configuration

  • Debug – Not applicable for ReScript builds (the option may appear but is not functional)

  • Edit Configurations – Open the run configuration editor to customize the build command

If no ReScript run configuration exists yet, clicking the icon creates a new one with default settings (Build command, project root as working directory).

Gutter run icons provide a zero-configuration way to trigger a build — new users can start compiling immediately without understanding run configurations or terminal commands.

Build Status Indicator

LSP Required

The status bar at the bottom of the IDE shows the current ReScript compilation status. This widget is only visible in projects that contain a rescript.json file.

Status States

Status

Display

Meaning

Compiling

ReScript: Compiling...

The compiler is currently running

Success

ReScript:

Build completed without errors or warnings

Error

ReScript: N error(s)

Build failed with N compilation errors

Warning

ReScript: N warning(s)

Build completed with N warnings

Unknown

ReScript

No compilation status received yet

How It Works

The build status indicator receives updates via the LSP protocol, not from the Run panel. Here is the flow:

  1. The ReScript Language Server monitors the compiler process

  2. When compilation state changes, the server sends a rescript/compilationStatus notification

  3. The plugin’s LSP client receives this notification and updates the RescriptCompilationStatusService

  4. The status bar widget listens for changes and refreshes its display

This means the status bar updates even if you run the compiler outside the IDE (e.g., from a terminal), as long as the Language Server is connected.

Tooltip Information

Hovering over the status bar widget shows a detailed tooltip:

  • “ReScript compiler is running…” during compilation

  • “ReScript compilation succeeded” on success

  • “ReScript compilation failed: 3 errors, 2 warnings” on error (with counts)

  • “ReScript compilation completed with 2 warnings” for warnings only

The status bar gives you at-a-glance visibility into the compiler state, so you always know whether your code is clean, broken, or still compiling — even when the Run panel is closed.

See also

Code Analysis shows detailed diagnostics (errors, warnings) inline in the editor.

Console Output

Native

Build output appears in the Run panel at the bottom of the IDE. The plugin enhances the raw console output with automatic file path linkification.

File Path Linkification

When the ReScript compiler outputs error or warning messages containing file paths, the plugin automatically converts them into clickable hyperlinks. The pattern recognized is:

path/to/file.res:line:column

For example, the compiler might output:

  Syntax error!

  src/App.res:10:5

  8 │ let greeting = "Hello"
  9 │
  10 │ let result = add(1, )

The path src/App.res:10:5 becomes a clickable link. Clicking it opens src/App.res in the editor with the cursor positioned at line 10, column 5.

Path Resolution

The plugin resolves file paths in two ways:

  1. Absolute paths – If the path is absolute and the file exists, it is used directly

  2. Relative paths – The path is resolved relative to the project root (the project’s base path)

Both .res and .resi file extensions are recognized by the link filter.

Supported Output Patterns

The console filter uses a regular expression that matches paths in the format <path>.res:<line>:<column> or <path>.resi:<line>:<column>. The line and column numbers in the compiler output are 1-based; the plugin automatically converts them to the 0-based offsets used by the IntelliJ editor.

Note

Console output filtering is applied to all console outputs in the project, not just ReScript run configurations. This means file paths in test output, script output, and other console panels are also linkified.

Clickable file paths in compiler output turn error messages into direct navigation links, so you jump straight to the problem line instead of manually opening the file and scrolling to the right position.

Run Anything

Native

Press Ctrl+Ctrl (double-tap Ctrl) to open the Run Anything dialog, then type a ReScript CLI command to execute it immediately without creating a run configuration.

Available Commands

Command

Description

rescript build

Compile the project

rescript build -w

Compile in watch mode

rescript clean

Clean build artifacts

rescript format

Format the project

Start typing rescript in the Run Anything dialog to see matching commands with auto-completion.

Note

Run Anything for ReScript is only available in projects that contain a rescript.json (or bsconfig.json) at the project root. The ReScript CLI must be installed in the project’s node_modules.

Run Anything lets you execute any ReScript CLI command with a quick keyboard shortcut, bypassing the overhead of creating a run configuration for one-off build or format operations.

Scratch File

Native

Create temporary ReScript files for quick experimentation without affecting your project.

How to Use

  1. File > New > Scratch File (or Ctrl+Alt+Shift+Insert)

  2. Select ReScript from the language list

  3. Write and experiment with code in the scratch file

Scratch files are stored in the IDE’s scratch directory (outside your project) and persist across IDE restarts. They support full syntax highlighting and code folding, making them ideal for testing small code snippets.

Use Cases

  • Quick prototyping — Try out an idea without creating a file in your project

  • Learning — Experiment with ReScript syntax and features

  • Debugging — Isolate and test a specific piece of logic

Scratch files give you a disposable workspace for quick experiments, so you can try out ideas without creating files in your project or polluting your source tree.

REPL

Native

An interactive ReScript execution environment available as a tool window.

Open: View > Tool Windows > ReScript REPL

How It Works

The REPL compiles and executes ReScript expressions using the project’s ReScript compiler and Node.js runtime. Each expression is wrapped in a temporary file, compiled to JavaScript, and executed, with the result displayed in the output panel.

Features

  • Expression evaluation — Type ReScript expressions and see results immediately

  • History navigation — Use Up/Down arrow keys to recall previous expressions

  • Project context — The REPL uses your project’s rescript.json configuration and dependencies

  • Clear output — Clear the output panel with the toolbar button

Requirements

  • ReScript compiler installed in the project’s node_modules

  • Node.js available on the system

The REPL provides an interactive feedback loop for testing expressions and exploring APIs without the overhead of creating files, compiling, and running — ideal for learning ReScript or verifying quick assumptions.

Worksheet Mode

Native

Interactively evaluate entire .resw (ReScript Worksheet) files with inline results displayed next to each expression.

How to Use

  1. Create a file with the .resw extension

  2. Write ReScript expressions, one per line

  3. Results appear as inline annotations next to each expression after evaluation

let x = 1 + 2          // => 3
let name = "ReScript"   // => "ReScript"
String.length(name)     // => 8

Features

  • Automatic evaluation — Expressions are evaluated when the file is saved or on demand

  • Inline results — Results appear as grayed-out annotations at the end of each line

  • Error display — Compilation errors are shown inline next to the offending expression

  • Full language support — Worksheets support the full ReScript syntax with access to project dependencies

Difference from REPL

  • REPL evaluates one expression at a time in an interactive session

  • Worksheet evaluates an entire file at once, showing all results side by side with the source code

Worksheets turn ReScript into a notebook-like experience where you see every expression’s result alongside the code, making them perfect for exploratory programming and documentation examples.

Debug Compiled JavaScript

Native

Press Alt+Shift+D to debug the compiled JavaScript output of the current .res file.

How It Works

  1. The plugin resolves the current .res file to its compiled .js output in lib/js/

  2. A debug session is launched using node --inspect-brk on the compiled file

  3. The IDE’s debugger connects to the Node.js inspector, allowing you to set breakpoints and step through the code

Requirements

  • The project must be compiled first — if the compiled .js file is not found, a message prompts you to build the project

  • Node.js must be available on the system

  • The JavaScript Debugger plugin must be installed (bundled with IntelliJ IDEA Ultimate and WebStorm)

Tip

Use this in combination with the Compiled JS Preview tool window to understand the compiled output before debugging.

When you need to debug runtime behavior, this lets you step through the compiled JavaScript with the IDE’s full debugger, connecting ReScript source logic to its actual JavaScript execution.