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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rollup/plugin-multi-entry

v6.0.1

Published

Use multiple entry points for a bundle

Downloads

184,311

Readme

npm size libera manifesto

@rollup/plugin-multi-entry

🍣 A Rollup plugin which allows use of multiple entry points for a bundle.

As an added bonus, the named exports from all entry points will be combined. This is particularly useful for tests, but can also be used to package a library.

Note: default exports cannot be combined and exported by this plugin. Only named exports will be exported.

Requirements

This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.

Install

Using npm:

npm install @rollup/plugin-multi-entry --save-dev

Usage

Suppose that we have three separate source files, each with their own export(s):

// batman.js
export const belt = 'utility';
// robin.js
export const tights = 'tight';
// joker.js
export const color = 'purple';

Then, create a rollup.config.js configuration file and import the plugin:

import multi from '@rollup/plugin-multi-entry';

export default {
  input: ['batman.js', 'robin.js', 'joker.js'],
  output: {
    dir: 'output'
  },
  plugins: [multi()]
};

Then call rollup either via the CLI or the API.

Using all three files above as entry points will yield a bundle with exports for belt, tights, and color.

Options

exports

Type: Boolean Default: true

If true, instructs the plugin to export named exports to the bundle from all entries. If false, the plugin will not export any entry exports to the bundle. This can be useful when wanting to combine code from multiple entry files, but not necessarily to export each entry file's exports.

entryFileName

Type: String Default: 'multi-entry.js'

entryFileName changes the name of the generated entry file. By default, it will override outputOptions.entryFileNames to be 'multi-entry.js'.

preserveModules

Type: Boolean Default: false

preserveModules is to be used in conjunction with output.preserveModules. If true, overrides the entryFileName option to be output.entryFileNames. If false, the plugin will respect the entryFileName option.

Supported Input Types

This plugin extends Rollup's input option to support multiple new value types, in addition to a String specifying a path to a file.

Glob

When using plugin-multi-entry, input values passed as a normal String are glob aware. Meaning you can utilize glob wildcards and other glob patterns to specify files as being input files.

export default {
  input: 'batcave/friends/**/*.js',
  plugins: [multi()]
  // ...
};

Array

An Array of String can be passed as the input. Values are glob-aware and can specify paths or globbed paths.

export default {
  input: ['party/supplies.js', 'batcave/friends/**/*.js'],
  plugins: [multi()]
  // ...
};

include and exclude

For fine-grain control, an Object may be passed containing include and exclude properties. These properties specify and Array of String representing paths (which are also glob-aware) which should be included as entry files, as well as files that should be excluded from any entries that may have been found with include, respectively.

export default {
  input: {
    // invite everyone!
    include: ['food.js', 'drinks.js', 'batcave/friends/**/*.js'],
    // except for the joker
    exclude: ['**/joker.js']
  },
  plugins: [multi()]
  // ...
};

Meta

CONTRIBUTING

LICENSE (MIT)