Skip to main content
Deno 2 is finally here 🎉️
Learn more

deno-rollup

Next-generation ES module bundler for Deno ported from Rollup.

Current version Current test status Deno docs PRs are welcome deno-rollup issues deno-rollup stars deno-rollup forks deno-rollup license deno-rollup is maintained deno-rollup repository visit count


Table of Contents

Overview

Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application.

This library extends Rollup so that it can be used within Deno scripts to bundle Deno code.

Installation

deno-rollup can be used either through a command line interface (CLI) with an optional configuration file, or else through its JavaScript API.

CLI

To install the CLI run:

deno install -f -q --allow-read --allow-write --allow-net --unstable https://deno.land/x/drollup@2.36.1+0.2.0/rollup.ts

And follow any suggestions to update your PATH environment variable.

You can then use the CLI to bundle your modules:

# compile to an ESM
rollup main.js --format es --name "myBundle" --file bundle.js

JavaScript API

You can import deno-rollup straight into your project to bundle your modules:

import { rollup } from "https://deno.land/x/drollup@2.36.1+0.2.0/mod.ts";

const options = {
  input: "./mod.ts",
  output: {
    dir: "./dist",
    format: "es" as "es",
    sourcemap: true,
  },
};

const bundle = await rollup(options);
await bundle.write(options.output);

Documentation

Please refer to the official Rollup Documentation. Specifically, please refer to the JavaScript API which this library extends to provide Deno compatibility.

Note: currently this library only supports the rollup method, it does not yet have support for the watch method.

Example

To run the example:

  1. Clone the deno-rollup repo locally:

    git clone git://github.com/cmorten/deno-rollup.git --depth 1
    cd deno-rollup
  2. Then enter the example directory and run the build script:

    cd example
    deno run --allow-read="./" --allow-write="./dist" --allow-net="deno.land" --unstable ./rollup.build.ts
  3. Further details are available in the example README.

Contributing

Contributing guide


License

deno-rollup is licensed under the MIT License.

The license for the Rollup library, which this library adapts, is available at ROLLUP_LICENSE.