rollup-plugin-purs
raw JSON → 1.0.38 verified Mon Apr 27 auth: no javascript maintenance
Rollup plugin to bundle PureScript modules into optimized JavaScript bundles. Current stable version is 1.0.38. It integrates PureScript compilation output with Rollup, offering tree shaking and advanced optimizations like uncurrying, inlining, dead code elimination, and constant propagation. Compared to purs bundle or webpack, it produces smaller file sizes (e.g., 35.7 kB vs 65.2 kB for a sample app). Requires manual PureScript compilation beforehand (e.g., with pulp build). Releases are infrequent; last update was in 2017. Not actively maintained, but functional for existing projects.
Common errors
error Error: Cannot find module 'rollup-plugin-purs' ↓
cause The package is not installed or npm install failed.
fix
Run 'npm install rollup-plugin-purs --save-dev'.
error SyntaxError: Unexpected token 'export' — maybe you need to use CommonJS require? ↓
cause Using require() instead of import on an ESM-only package.
fix
Use 'import purs from "rollup-plugin-purs"' in an ES module context or set type:"module" in package.json.
error Error: The 'dest' option is deprecated. Use 'output.file' instead. ↓
cause Rollup version mismatch: dest was used in older Rollup config.
fix
Use output.file instead of dest, or use Rollup ^0.41.6 which supports dest.
Warnings
gotcha Plugin does not compile PureScript; you must run pulp build or purs compile first. ↓
fix Run 'pulp build -- --source-maps' or equivalent before running rollup.
gotcha Requires Rollup version ^0.41.6; incompatible with newer Rollup versions (>=1.0.0). ↓
fix Use an older Rollup version (e.g., 0.41.6) or consider alternatives.
gotcha assumePureVars optimization can break programs with impure FFI or unsafe functions. ↓
fix Set assumePureVars: false in options if using impure FFI.
gotcha debug: true may display warnings about dynamic exports, require, or module; can be suppressed with comment pragmas. ↓
fix Add // rollup-plugin-purs ignore dynamic exports comments in source files.
Install
npm install rollup-plugin-purs yarn add rollup-plugin-purs pnpm add rollup-plugin-purs Imports
- default wrong
const purs = require('rollup-plugin-purs')correctimport purs from 'rollup-plugin-purs' - purs wrong
import { purs } from 'rollup-plugin-purs'correctimport purs from 'rollup-plugin-purs' - Plugin wrong
import { Plugin } from 'rollup-plugin-purs'correctimport type { Plugin } from 'rollup'
Quickstart
// rollup.config.js
import purs from 'rollup-plugin-purs';
export default {
input: 'src/Main.purs',
output: {
file: 'bundle.js',
format: 'iife',
sourcemap: true
},
plugins: [purs()]
};
// Build: run 'pulp build -- --source-maps' first, then 'rollup -c'