plugin-auto-install icon indicating copy to clipboard operation
plugin-auto-install copied to clipboard

This module has moved and is now available at @rollup/plugin-auto-install / https://github.com/rollup/plugins/blob/master/packages/auto-install

Moved

This module has moved and is now available at @rollup/plugin-auto-install. Please update your dependencies. This repository is no longer maintained.

@rollup/plugin-auto-install

Automatically install dependencies that are imported by your bundle, but aren't yet in package.json.

Usage

Install in the usual fashion...

npm install -D @rollup/plugin-auto-install

...then add to your plugins array, ensuring that it goes before rollup-plugin-node-resolve:

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

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

Options

auto({
  // the location of your package.json — this will be created
  // if it doesn't already exist, since package managers need
  // to populate the `dependencies` field
  pkgFile: 'package.json',

  // whether to use npm or yarn. This defaults to yarn if a
  // yarn.lock file exists, or npm otherwise
  manager: 'yarn'
})

Credits

Thanks to Guillermo Rauch for the idea.

License

LIL