rollup-plugin-multi-input

rollup plugin for bundling modular libraries

MIT 29 个版本
安装
npm install rollup-plugin-multi-input
yarn add rollup-plugin-multi-input
pnpm add rollup-plugin-multi-input
bun add rollup-plugin-multi-input
README

rollup-plugin-multi-input

CD CI codecov npm version semantic-release

⚠️ Deprecation notice

rollup-plugin-multi-input will be deprecated in the future. We are migrating to modular-library.

:warning: Do you really need rollup-plugin-multi-input?

Take a look at the rollup preserveModules and preserveModulesRoot options.

If your project uses Node.js 22 or newer, you can migrate to modular-library, which includes a Rollup plugin and can be used instead of rollup-plugin-multi-input.

Migration example (Node.js >= 22)

From:

import multiInput from 'rollup-plugin-multi-input';

export default {
  input: ['src/**/*.js'],
  output: {
    format: 'esm',
    dir: 'dist'
  },
  plugins: [multiInput()],
};

To:

import modularLibrary from 'modular-library/rollup';

export default {
  input: ['src/**/*.js'],
  output: {
    format: 'esm',
    dir: 'dist'
  },
  plugins: [modularLibrary()],
};

A rollup plugin to bundle modular libraries with sub directories.

  • Use multiple entry points.
  • Use glob in entries.
  • Preserve src tree structure in the dist folder.

Install

Install via npm or yarn.

npm i -D rollup-plugin-multi-input
yarn add rollup-plugin-multi-input

Setup

In the rollup configuration

import multiInput from 'rollup-plugin-multi-input';

export default {
    // use glob in the input
    input: ['src/**/*.js'],
    output: {
      format: 'esm',
      dir: 'dist'
    },
    plugins: [ multiInput() ],
};

If using a rollup version lower than 1.0.0 enable experimentalCodeSplitting.

It's possible to mix input type.

  • use glob in array
    input: ['src/**/*.js']
    
  • use object input configuration
    // DO 👍
    input: [{
      output1: 'src/output1.js'
    }]
    // DON'T ❌ (glob not supported yet)
    input: [{
      output1: 'src/**/*.js'
    }]
    
  • use glob string and object configuration
    input: ['src/more/**/*.js', 'src/more2/**/*.js', {
      output1: 'src/output1.js'
    }]
    

Options

relative 'src/'

Specify the relative path to use in the dist folder.

Example:

import multiInput from 'rollup-plugin-multi-input';

export default {
    input: ['src/bar.js', 'src/foo/bar.js'],
    output: {
      format: 'esm',
      dir: 'dist'
    },
    plugins: [ multiInput({ relative: 'src/' }) ],
};
// create the files dist/bar.js and dist/foo/bar.js

transformOutputPath

A callback for transforming output file path.

Example:

import multiInput from 'rollup-plugin-multi-input';
import path from 'path';

export default {
    input: ['src/bar.js', 'src/foo/bar.js'],
    output: {
      format: 'esm',
      dir: 'dist'
    },
    plugins: [ multiInput({ 
        relative: 'src/', 
        transformOutputPath: (output, input) => `awesome/path/${path.basename(output)}`, 
    }) ],
};
// create the files awesome/path/bar.js and awesome/path/foo/bar.js

glob {}

fast-glob object configuration.

hideBuildStartMessage

Hide the build start message.

版本列表
1.9.0 2026-04-12
1.8.0 2026-03-07
1.7.0 2026-01-15
1.6.0 2025-10-22
1.5.0 2024-07-26
1.4.2 2024-07-04
1.4.1 2023-03-25
1.4.0 2023-03-25
1.3.3 2023-01-19
1.3.2 2023-01-08
1.3.1 2021-05-27
1.3.0 2021-05-19
1.2.0 2020-12-23
1.1.1 2020-02-25
1.1.0 2020-02-25
1.0.3 2019-11-17
1.0.2-alpha-1 2019-06-25
1.0.2 2019-06-25
1.0.1 2019-06-21
1.0.0 2019-05-26
0.2.2 2019-04-24
0.2.1 2019-03-27
0.1.3 2019-01-22
0.1.2 2019-01-22
0.1.1 2018-12-13
0.1.0 2018-12-13
0.0.3-alpha 2018-12-13
0.0.2-alpha 2018-12-13
0.0.1-alpha 2018-12-13