From f884af6b9746336ee126c20f4f70768081926eb7 Mon Sep 17 00:00:00 2001 From: Josh Vlk Date: Sat, 18 May 2024 10:25:07 -0400 Subject: [PATCH] Add section to README explaining settings to support ESM and CJS --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e165244d..6ba0b53d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ Open it so it's available in the global scope. } ``` +## ESM and CJS +To use this library with CommonJS modules you should set the file extension in your project's `rescript.json` to `.res.js`, `.js`, `.res.cjs`, or `.cjs`. This will work with older versions of Node and most web projects using a bundler. + +To use this library with EcmaScript modules you should set the file extension in your project's `rescript.json` to `.res.mjs`, or `.mjs`. +This will work with newer versions of Node and web projects using a modern bundler like Vite. + ## What it looks like All relevant standard library modules are designed to be available directly in