rollup-plugin-bucklescript
raw JSON → 0.7.0 verified Mon Apr 27 auth: no javascript maintenance
A Rollup plugin that integrates with the BuckleScript compiler to bundle ReasonML and OCaml code into JavaScript. Version 0.7.0 is the latest stable release (last updated in 2020). It works by running bsb during the build, consuming compiled ES6 modules. Key differentiators include minimal configuration (reads bsconfig.json), support for in-source builds, and options to control warnings and standard library inclusion. Compared to webpack's bs-loader, it fits the Rollup ecosystem better for library authors. Maintenance is intermittent; the repo has low activity.
Common errors
error Error: Cannot find module 'rollup-plugin-bucklescript' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install --save-dev rollup-plugin-bucklescript'.
error Error: [BABEL] unknown: Cannot find module 'bs-platform' ↓
cause Peer dependency bs-platform is missing.
fix
Run 'npm install --save-dev bs-platform'.
Warnings
gotcha Must set 'package-specs' in bsconfig.json to 'es6' for Rollup to consume ES modules. ↓
fix Add '"package-specs": ["es6"]' to bsconfig.json.
gotcha If using ReasonReact, using 'es6' module format can break JSX compilation; follow Rollup error messages to add aliases. ↓
fix Check the react example in the repo for workarounds.
deprecated BuckleScript is in maintenance mode; the project encourages migration to ReScript. ↓
fix Consider using ReScript and its official build tools.
gotcha Plugin runs bsb during build; bsb must be installed and configured correctly. ↓
fix Ensure bs-platform is installed as a devDependency and bsconfig.json is valid.
Install
npm install rollup-plugin-bucklescript yarn add rollup-plugin-bucklescript pnpm add rollup-plugin-bucklescript Imports
- default wrong
const bucklescript = require('rollup-plugin-bucklescript')correctimport bucklescript from 'rollup-plugin-bucklescript' - bucklescript wrong
const { bucklescript } = require('rollup-plugin-bucklescript')correctimport bucklescript from 'rollup-plugin-bucklescript' - bucklescript wrong
import { bucklescript } from 'rollup-plugin-bucklescript'correctimport bucklescript from 'rollup-plugin-bucklescript'
Quickstart
// rollup.config.js
import bucklescript from 'rollup-plugin-bucklescript';
export default {
input: 'src/main.re',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
plugins: [
bucklescript()
]
};