This is the latest docs version
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
  • Twitter
  • GitHub
  • Forum
Language Manual
Overview
  • Introduction
  • Installation
  • Migrate to v11
  • Editor Plugins
  • Try
Language Features
  • Overview
  • Let Binding
  • Type
  • Primitive Types
  • Tuple
  • Record
  • Object
  • Variant
  • Polymorphic Variant
  • Null, Undefined and Option
  • Array & List
  • Function
  • If-Else & Loops
  • Pipe
  • Pattern Matching / Destructuring
  • Mutation
  • JSX
  • Exception
  • Lazy Value
  • Promises
  • Async / Await
  • Tagged templates
  • Module
  • Import & Export
  • Attribute (Decorator)
  • Reserved Keywords
  • Equality and Comparison
Advanced Features
  • Extensible Variant
  • Scoped Polymorphic Types
JavaScript Interop
  • Interop Cheatsheet
  • 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
  • Inlining Constants
  • Use Illegal Identifier Names
  • Generate Converters & Helpers
  • Browser Support & Polyfills
  • Libraries & Publishing
  • TypeScript
Build System
  • Overview
  • Configuration
  • Configuration Schema
  • External Stdlib
    • Configuration
  • Pinned Dependencies
  • Interop with JS Build Systems
  • Performance
  • Warning Numbers
Guides
  • Converting from JS
Extra
  • Newcomer Examples
  • Project Structure
  • FAQ
Docs / Language Manual / External Stdlib
Edit

External Stdlib

Since 9.0

Your ReScript project depends on the rescript package as a devDependency, which includes our compiler, build system and runtime like Belt. However, you had to move it to dependency in package.json if you publish your code:

  • To Docker or other low-storage deployment devices.

  • For pure JS/TS consumers who probably won't install rescript in their own project.

In these cases, the size or mere presence of rescript can be troublesome, since it includes not just our necessary runtime like Belt, but also our compiler and build system.

To solve that, we now publish our runtime as a standalone package at @rescript/std, whose versions mirror rescript's. Now you can keep rescript as a devDependency and have only @rescript/std as your runtime dependency.

This is an advanced feature. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature.

Configuration

Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this:

SH
npm install rescript@11.0.1 --save-dev npm install @rescript/std@11.0.1

Then add this to rescript.json:

JSON
{ // ... "external-stdlib" : "@rescript/std" }

Now the compiled JS code will import using the path defined by external-stdlib. Check the JS output tab:

ReScriptJS output
Array.forEach([1, 2, 3], num => Console.log(num))

Make sure the version number of rescript and @rescript/std match in your package.json to avoid running into runtime issues due to mismatching stdlib assumptions.

Configuration SchemaPinned Dependencies

© 2024 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on