1. @rollup/plugin-auto-install
Automatically install dependencies that are imported by a bundle
@rollup/plugin-auto-install
Package: @rollup/plugin-auto-install
Created by: rollup
Last modified: Thu, 05 Oct 2023 11:59:40 GMT
Version: 3.0.5
License: MIT
Downloads: 2,193
Repository: https://github.com/rollup/plugins

Install

npm install @rollup/plugin-auto-install
yarn add @rollup/plugin-auto-install

npm
size
libera manifesto

@rollup/plugin-auto-install

🍣 A Rollup plugin which automatically installs dependencies that are imported by a bundle, even if not yet in package.json.

Requirements

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

Install

Using npm:

 npm install @rollup/plugin-auto-install --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

 import auto from '@rollup/plugin-auto-install';
import resolve from '@rollup/plugin-node-resolve';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [auto(), resolve()]
};

Note: ensure that this plugin is added to the plugins array before @rollup/plugin-node-resolve.

Then call rollup either via the CLI or the API.

Options

pkgFile

Type: String

Default: '{cwd}/package.json'

Specifies the location on disk of the target package.json file. If the file doesn't exist, it will be created by the plugin, as package managers need to populate the dependencies property.

manager

Type: 'pnpm'|'yarn'|'npm'

Default: determined at runtime

Specifies the package manager to use. If not specified:

  • 'pnpm' if pnpm-lock.yaml exists
  • 'yarn' if yarn.lock exists
  • 'npm' otherwise

Credits

Thanks to Guillermo Rauch for the idea.

Meta

CONTRIBUTING

LICENSE (MIT)

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin