@zeekay/rollup-plugin-node-resolve

Rollup.js plugin which resolves third-party dependencies in node_modules

Usage no npm install needed!

<script type="module">
  import zeekayRollupPluginNodeResolve from 'https://cdn.skypack.dev/@zeekay/rollup-plugin-node-resolve';
</script>

README

@zeekay/rollup-plugin-node-resolve

NPM version Build Status Coverage Status Dependency Status Gitter chat

Locate modules using the Node resolution algorithm, for using third party modules in node_modules. Differs in the following ways from rollup-plugin-node-resolve:

  • Automatically degrades from 'module' -> 'jsnext:main' -> 'main' -> 'index.js'
  • Correctly resolves symlinked packages.
  • Prefers entry-module basedir as basedir for resolution (ideal for bundled apps, prevents duplication of shared modules).

Originally developed as part of Handroll.

Install

$ npm install @zeekay/rollup-plugin-node-resolve --save-dev

Usage

Add the following code to your project's rollup.config.js:

import resolve  from '@zeekay/rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
  entry: 'index.js',
  plugins: [
    resolve({
      // defaults
      basedir:        path.dirname('index.js'),
      browser:        false,
      extensions:     ['.js', '.json', '.coffee', '.pug', '.styl'],
      preferBuiltins: true,
      skip:           []
    }),
    commonjs()
  ]
};

License

MIT