@rollup/plugin-multi-entry
Use multiple entry points for a bundle
Last updated 3 years ago by shellscape .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @rollup/plugin-multi-entry 
SYNC missed versions from official npm registry.

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)

Current Tags

  • 6.0.1                                ...           latest (a year ago)

8 Versions

  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.1                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE