Registry / web-framework / eleventy-plugin-rollup

eleventy-plugin-rollup

JSON →
library1.3.0jsnpmunverified

An Eleventy plugin that integrates Rollup into the build pipeline, enabling per-page JavaScript bundling and code splitting. Version 1.3.0 is the current stable release, updated as needed. Unlike running Rollup separately, this plugin shares the Eleventy build context, reducing duplicate bundles and allowing shared modules across pages. It supports both explicit Rollup configuration via options or an external config file, and provides a Liquid/Nunjucks shortcode for including bundled scripts. Notable alternatives like eleventy-plugin-esbuild or manual PostCSS/Webpack setups require more manual wiring. Requires Rollup as a peer dependency; supports Eleventy 1.x and 2.x.

npm install eleventy-plugin-rollup
INSTALL
IMPORT
SIG · ELEVENTY-PLUGIN-RO
E
eleventy-plugin-rollup
web-frameworkjavascriptv1.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const rollupPlugin = require('eleventy-plugin-rollup');
import rollupPlugin from 'eleventy-plugin-rollup';
Package does not provide a named export; use default CommonJS require. ESM import may require .default.
rollupPlugin
eleventyConfig.addPlugin(rollupPlugin, { rollupOptions: { /* ... */ } });
eleventyConfig.addPlugin(rollupPlugin.default, ...);
If using ESM import, the default is wrapped; avoid .default chain. Use require for simplicity.
shortcode
{% rollup "assets/js/main.js" %}
{% rollup "assets/js/main.js" | url %} with no shortcode
The shortcode defaults to 'rollup' and expects a relative path. Use the | url filter only if your template engine requires it (e.g., Liquid).

Shows how to add the plugin with explicit Rollup options in an Eleventy config file.

// .eleventy.js const rollupPlugin = require('eleventy-plugin-rollup'); module.exports = function (eleventyConfig) { eleventyConfig.addPlugin(rollupPlugin, { rollupOptions: { output: { format: 'es', dir: '_site/js', }, }, }); // ... other config };
Debug
Known issues
breakingBreaking: rollupOptions no longer accepts output.format as 'iife' when used with multiple entry points; use 'es' or 'system'.
fix
Set output.format to 'es' or 'system' in rollupOptions.output.
affects: >=1.0.0
deprecatedrollupOptions as a path string to a config file is deprecated; prefer passing options object directly
fix
Replace rollupOptions: 'rollup.config.js' with rollupOptions: require('./rollup.config.js') or inline the options.
affects: <1.3.0
gotchaShortcode uses require() internally; do not import rollup plugins that are ESM-only in the shortcode context
fix
Use CommonJS-compatible Rollup plugins or ensure your config file is transpiled/required correctly.
affects: >=1.0.0
gotchaIf you use useAbsoluteScriptPaths: true, you must set importScriptsAbsoluteFrom to match your deployment path (defaults to eleventyConfig.dir.output)
fix
Set importScriptsAbsoluteFrom to the absolute base URL path (e.g., '/subdir/') in the plugin options.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The rollupOptions property is required.
Missing or empty rollupOptions in plugin configuration.
fix
Add rollupOptions object with valid Rollup config (e.g., { output: { format: 'es', dir: '_site/js' } }).
rollup is not defined (shortcode error)
Using the shortcode without adding the plugin or misspelling the shortcode name.
fix
Ensure eleventyConfig.addPlugin(rollupPlugin, ...) is called and the shortcode matches (default: 'rollup').
TypeError: Cannot read properties of undefined (reading 'output')
rollupOptions does not contain output.dir or output.file.
fix
Add output configuration: { output: { dir: '_site/js', format: 'es' } }.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency; required to perform actual bundling
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
eleventy-plugin-rollup — npm install eleventy-plugin-rollup · libregistry