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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rescript/vite-plugin

v0.1.0

Published

The official ReScript plugin for Vite

Readme

@rescript/vite-plugin

The official ReScript plugin for Vite

The plugin passes source maps generated by the ReScript compiler into Vite, so development tools and production bundles can map generated JavaScript back to the original .res and .resi source files.

Installation

npm install --save-dev @rescript/vite-plugin

Usage

[!NOTE] Source-map support will be released in ReScript 13 but is not published yet. The runnable example uses a compiler preview in the meantime.

Enable source maps in rescript.json:

{
  "sourceMap": {
    "enabled": "dev",
    "mode": "linked",
    "sourcesContent": true
  }
}

Then add the plugin to vite.config.ts:

import { sourceMap } from "@rescript/vite-plugin";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [sourceMap()],
});

The plugin supports ReScript's linked, inline, and hidden source-map modes. It only applies a source map when at least one mapped source is a .res or .resi file.

Production builds

Use "enabled": "always" when source maps should also be generated by rescript build. Vite must be configured to emit its final bundle source maps separately:

export default defineConfig({
  plugins: [sourceMap()],
  build: {
    sourcemap: true,
  },
});

Set Vite's build.sourcemap to "hidden" when the maps should be emitted without adding a sourceMappingURL comment to the production bundle.

[!CAUTION] Source maps with sourcesContent enabled contain the original ReScript source. Choose the ReScript and Vite source-map settings appropriate for how the production artifacts will be distributed.

Options

The plugin inspects .js, .mjs, and .cjs modules and skips node_modules by default. Use include and exclude to customize that behavior:

export default defineConfig({
  plugins: [
    sourceMap({
      include: ["src/**/*.res.mjs", "generated/**/*.res.js"],
      exclude: "vendor/**",
    }),
  ],
});

Pass exclude: null to inspect dependencies in node_modules as well.

Example

examples/basic is a minimal ReScript and Vite application that uses this package through its public package exports. From the repository root, run:

yarn example:dev

This compiles ReScript once and starts Vite. For live .res recompilation, run the compiler watcher in a second terminal:

yarn workspace rescript-vite-plugin-example rescript:watch

Use yarn example:build to compile ReScript and create a production bundle. The example is also exercised by yarn test as an end-to-end source-map smoke test. It temporarily uses a ReScript 13 compiler preview and requires Node.js 22.12 or newer.

Development

This repository uses Yarn 4.12.0 through Corepack:

corepack enable
yarn install
yarn check
yarn test
yarn build

Changesets

Changes that affect the published package should include a changeset. Run:

yarn changeset

Commit the generated .changeset/*.md file with the change. Documentation and other changes that do not affect the published package do not need a changeset.

To apply pending changesets and publish a release, maintainers can run:

yarn changeset version
yarn changeset publish

License

MIT