The easiest way to serve a rollup bundle.
Last updated 4 years ago by mindeavor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rollup-endpoint 
SYNC missed versions from official npm registry.


Easily serve a JavaScript bundle – bundled with rollup.js – from an express.js endpoint. No grunt/gulp, no build files, no required configuration – just pure data.


$ npm install rollup-endpoint --save

Usage - Easy Version

Assuming you have the following directory structure:

└── main.js


Then you can write the following as your server.js:

// server.js
var rollup = require('rollup-endpoint');
var app  = require('express')();

app.get('/assets/app-bundle.js', rollup.serve({
  entry: __dirname + '/client/main.js'

console.log("Listening on port 5555...");

Then run node server.js.

Now any GET request to localhost:5555/assets/app-bundle.js will compile and rollup the JS file located at ./client/main.js. Any import statements within main.js will be included in the final output, too.

Advanced Usage

rollup-endpoint passes all your options along to rollup itself, so you can specify any option as described in the rollup JavaScript API.

When the NODE_ENV environment variable is set to production, rollup-endpoint will automatically cache and gzip your bundle output.


Plugins are configured in the same way as rollup's JavaScript API.

Here's a useful example. In production, you might want to transpile your code to ES5, as well as minify it. However, you probably don't want waste CPU cycles doing the same in development. Here's how you can do that:

var rollupOptions = { entry: 'my-file.js' };

if ( process.env.NODE_ENV === 'production' ) {
  rollupOptions.plugins = [

app.get('/app-bundle.js', rollup.serve(rollupOptions))

Generate Options

If you need to configure the rollup generate options, you can pass them as generateOptions:

app.get('/assets/app-bundle.js', rollup.serve({
  entry: __dirname + '/client/main.js',
  generateOptions: {
    format: 'amd',
    sourceMap: true, // defaults to `false` in production

Current Tags

  • 0.2.2                                ...           latest (4 years ago)

3 Versions

  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 3
Last Month 9
Dependencies (1)
Dev Dependencies (4)
Dependents (0)

Copyright 2014 - 2016 © |