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

rollup-plugin-multi-input

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-multi-input

rollup plugin for bundling modular libraries

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
decreased by-2.61%
Maintainers
0
Weekly downloads
 
Created
Source

rollup-plugin-multi-input

CD CI codecov npm version semantic-release

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

Take a look at the rollup preserveModules and preserveModulesRoot options.

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.

Keywords

FAQs

Package last updated on 26 Jul 2024

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