ReScript Compiler
raw JSON → 9.0.2 verified Fri May 01 auth: no javascript
ReScript (bs-platform) is a strongly typed language that compiles to efficient, readable JavaScript. This package provides the compiler, standard library (Stdlib, Belt), and build system (ninja-based). Current latest stable version is 12.2.0 (as of this entry), with v13 in alpha. Release cadence is roughly quarterly, with breaking changes in major versions. Key differentiators vs TypeScript: sound type system, no type errors at runtime, fast compilation, and seamless interop with JavaScript via special syntax and attributes. The package is primarily for tooling and compiler development; most users should use the `rescript` npm package or ReScript via the VSCode extension.
Common errors
error Fatal error: Parmatch.all_record_args ↓
cause Pattern matching on empty dict/record patterns in older versions.
fix
Update to ReScript v12.2.0 or later. If you must stay on an older version, avoid matching empty dict/record patterns.
error Cannot find module 'bs-platform' ↓
cause Trying to require or import 'bs-platform' after it has been deprecated and possibly not installed.
fix
Install the 'rescript' package and use 'require('rescript')' or adjust your build pipeline to use the 'rescript' package instead.
error exponential compilation blowup with large unboxed variants and dict pattern matching ↓
cause A bug in ReScript v12.0.0 that caused exponential time/memory usage.
fix
Update to v12.0.1 or later where this is fixed. If you cannot update, refactor large unboxed variants.
error Intl.Collator.compare: expected int, got float ↓
cause Breaking change in v13.0.0-alpha: the return type changed from int to Ordering.t (float).
fix
Update your code to handle Ordering.t (float) or use the previous version if you depend on int.
Warnings
deprecated The 'bs-platform' package is deprecated. Use the 'rescript' package instead. ↓
fix Run 'npm install rescript' and update your imports and build config to use the 'rescript' package.
breaking Since v13.0.0-alpha, 'bsconfig.json' is no longer supported. Use 'rescript.json'. ↓
fix Rename 'bsconfig.json' to 'rescript.json' and adjust the schema if needed.
breaking Since v13.0.0-alpha, the legacy build system is removed. Only the modern build system is supported. ↓
fix Use 'npx rescript build' instead of 'npx rescript-legacy build'. Ensure your rescript.json is configured for the modern build system.
breaking In v13.0.0-alpha, 'Int.fromString' and 'Float.fromString' use stricter number parsing and no longer accept an explicit radix argument. ↓
fix Remove the radix argument from calls to Int.fromString and Float.fromString. Use parseInt for radix-based parsing.
breaking In v13.0.0-alpha, the deprecated '%external' extension has been removed. ↓
fix Replace '%external' with the appropriate ReScript binding syntax, e.g., using '@external' decorator.
breaking In v12.0.0, the build system changed fundamentally. The 'bsc' and 'bsb' commands are deprecated. ↓
fix Use 'npx rescript build' instead of 'bsc' or 'bsb'. Update your rescript.json to the new schema.
Install
npm install bs-platform yarn add bs-platform pnpm add bs-platform Imports
- Belt wrong
const Belt = require('bs-platform').Beltcorrectimport Belt from 'rescript' - Js wrong
import * as Js from 'bs-platform'correctopen Js; - Intl wrong
import Intl from 'bs-platform'correctopen Intl; - rescript wrong
npm install bs-platformcorrectnpm install rescript
Quickstart
// Create a new ReScript project
mkdir my-project
cd my-project
npm init -y
npm install rescript
// Create rescript.json with minimal config
cat > rescript.json << 'EOF'
{
"name": "my-project",
"version": "0.1.0",
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": []
}
EOF
mkdir src
cat > src/Demo.res << 'EOF'
let greeting = "Hello, ReScript!"
let add = (a: int, b: int) => a + b
let result = add(2, 3)
Js.log(greeting)
Js.log(result)
EOF
// Compile
npx rescript build
// Run the output (src/Demo.bs.js)
node src/Demo.bs.js