npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-bucklescript

v0.7.0

Published

rollup plugin for using buckescript compiler

Downloads

244

Readme

rollup-plugin-bucklescript

dependency-status npm version

bucklescript compiler plugin for rollup.js

works with both ReasonML and OCaml

Usage

Installation

First install bs-platform in your project

npm i -D bs-platform

create a bsconfig.json for Bucklescript in the root directory of your project

and remember to specify "package-specs" as ["es6"], so that rollup can consume it.

{
  "name": "hello",
  "sources": ["src"],
  "bs-dependencies": ["reason-react"],
  "reason": {
    "react-jsx": 2
  },
  "package-specs": ["es6"],
  "refmt": 3
}

Finally, install rollup-plugin-bucklescript

npm i -D rollup-plugin-bucklescript

and add it to your rollup config.

import bucklescript from 'rollup-plugin-bucklescript'

export default {
  input: 'src/main.re',
  output: {
    file: 'dist/main.js',
    format: 'cjs',
  },
  plugins: [
    bucklescript()
  ],
}

Options

All the settings are taken from bsconfig.json, but few options can be overridden.

include and exclude

each a minimatch pattern, or array of minimatch patterns, which determines which files are complied by Bucklescript. By default all .re and .ml are included and all .rei and .mli are excluded.

module

To specify bucklescript output type for rollup to consume.

Note: Please check the Caveats section

...

plugins: [
  bucklescript({
    module: 'es6'
  })
]

inSource

To use bs-loader with bsb's in-souce builds, add the inSource option to your loader config:

...

plugins: [
  bucklescript({
    inSource: false
  })
]

cwd

This option specifies what directory to run bsb from.

...

plugins: [
  bucklescript({
    cwd: 'path/to/dir'
  })
]

showWarnings

Controls whether bsb compile warnings are shown. Defaults to true.

...

plugins: [
  bucklescript({
    showWarnings: true
  })
]

includeStandardLibrary

Note: This is an advance feature and may not work as intended Bucklescript comes with OCaml standard library complied to javascript. Choose whether to bundle functions from standard library. Defaults to true.

Examples

Check the examples folder in the github repo.

Caveats

Please use es6 for module option as rollup works only with es modules. But this breaks integration with with react, thought it can be easily solved by following the helpful error message provided by rollup.

or check the react example folder.

Acknowledgement

  • bs-loader - A webpack plugin for bucklescript, for providing bsb-js and read-bsconfig.
  • Reason team at facebook and all the project contributors for making ReasonML
  • @bobzhang and all contributors of bucklescript.

License

MIT