0.2.1 • Published 2 years ago

rollup-plugin-deps-external v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

rollup-plugin-deps-external

Rollup plugin to automatically exclude package.json dependencies from your bundle.

Most of the code is borrowed from the excellent rollup-plugin-auto-external package.

Install

npm install --save-dev rollup-plugin-deps-external

Usage

Add the depsExternal plugin to your Rollup configuration:

import depsExternal from 'rollup-plugin-deps-external';

export default {
  input: 'index.js',
  plugins: [depsExternal()],
};

You can pass options to the plugin as well:

import path from 'path';
import depsExternal from 'rollup-plugin-deps-external';

export default {
  input: 'index.js',
  plugins: [
    depsExternal({
      builtins: false,
      dependencies: true,
      packagePath: path.resolve('./packages/module/package.json'),
      peerDependencies: false,
    }),
  ],
};

rollup-plugin-deps-external is compatible with an existing Rollup external function.

import depsExternal from 'rollup-plugin-deps-external';

export default {
  input: 'index.js',
  external: (id) => id.includes('babel-runtime'),
  plugins: [depsExternal()],
};

Options

builtins

Type: boolean \ Default: true

Add all Node.js builtin modules as externals.

dependencies

Type: boolean \ Default: true

packagePath

Type: string \ Default: process.cwd()

Path to a package.json file or its containing directory.

peerDependencies

Type: boolean \ Default: true.