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 Run → Edit Configurations → + → ReScript.
Available Commands¶
Command |
CLI Arguments |
Description |
|---|---|---|
Build |
|
One-shot compilation of the entire project |
Build (Watch) |
|
Continuous compilation with file watching |
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 yoursrc/folder structureIf 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
.resor.resifile, the compiler performs an incremental recompilation of only the affected files and their dependentsBuild 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+F2Watch 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.jsfiles within itAlso removes
.ast,.cmt,.cmti, and other intermediate build artifactsUse this when you encounter stale build artifacts, unexplained compilation errors, or after changing
rescript.jsonconfigurationAfter cleaning, you need to run a full Build to regenerate all output files
Configuration Options¶
Working directory – The project root (where
rescript.jsonis located). The plugin uses this path to locate therescriptCLI and as the working directory for the compiler process.Command – Build, Build (Watch), or Clean.
Additional arguments – Extra CLI flags passed to the
rescriptcommand (e.g.,--verbose).
CLI Detection¶
The plugin automatically locates the rescript CLI binary by searching in the following order:
<working directory>/node_modules/.bin/rescript<project root>/node_modules/.bin/rescriptParent 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 |
|
The compiler is currently running |
Success |
|
Build completed without errors or warnings |
Error |
|
Build failed with N compilation errors |
Warning |
|
Build completed with N warnings |
Unknown |
|
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:
The ReScript Language Server monitors the compiler process
When compilation state changes, the server sends a
rescript/compilationStatusnotificationThe plugin’s LSP client receives this notification and updates the
RescriptCompilationStatusServiceThe 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:
Absolute paths – If the path is absolute and the file exists, it is used directly
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 |
|---|---|
|
Compile the project |
|
Compile in watch mode |
|
Clean build artifacts |
|
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¶
File > New > Scratch File (or
Ctrl+Alt+Shift+Insert)Select ReScript from the language list
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.jsonconfiguration and dependenciesClear output — Clear the output panel with the toolbar button
Requirements¶
ReScript compiler installed in the project’s
node_modulesNode.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¶
Create a file with the
.reswextensionWrite ReScript expressions, one per line
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¶
The plugin resolves the current
.resfile to its compiled.jsoutput inlib/js/A debug session is launched using
node --inspect-brkon the compiled fileThe 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
.jsfile is not found, a message prompts you to build the projectNode.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.