Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rollup/plugin-multi-entry

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-multi-entry

Use multiple entry points for a bundle

  • 6.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

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)

Keywords

FAQs

Package last updated on 24 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc