rollup-plugin-node-resolve eslint travis-ci npm

Use the Node.js resolution algorithm with Rollup (formerly rollup-plugin-npm)

2 years after

rollup-plugin-node-resolve

This plugin used to be called rollup-plugin-npm

Locate modules using the Node resolution algorithm, for using third party modules in node_modules

Installation

npm install --save-dev rollup-plugin-node-resolve

Usage

import { rollup } from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';

rollup({
  entry: 'main.js',
  plugins: [
    nodeResolve({
      // use "module" field for ES6 module if possible
      module: true, // Default: true

      // use "jsnext:main" if possible
      // – see https://github.com/rollup/rollup/wiki/jsnext:main
      jsnext: true,  // Default: false

      // use "main" field or index.js, even if it's not an ES6 module
      // (needs to be converted from CommonJS to ES6
      // – see https://github.com/rollup/rollup-plugin-commonjs
      main: true,  // Default: true

      // if there's something your bundle requires that you DON'T
      // want to include, add it to 'skip'. Local and relative imports
      // can be skipped by giving the full filepath. E.g., 
      // `path.resolve('src/relative-dependency.js')`
      skip: [ 'some-big-dependency' ],  // Default: []

      // some package.json files have a `browser` field which
      // specifies alternative files to load for people bundling
      // for the browser. If that's you, use this option, otherwise
      // pkg.browser will be ignored
      browser: true,  // Default: false

      // not all files you want to resolve are .js files
      extensions: [ '.js', '.json' ],  // Default: ['.js']

      // whether to prefer built-in modules (e.g. `fs`, `path`) or
      // local ones with the same names
      preferBuiltins: false  // Default: true

    })
  ]
}).then( bundle => bundle.write({ dest: 'bundle.js', format: 'iife' }) );

// alongside rollup-plugin-commonjs, for using non-ES6 third party modules
import commonjs from 'rollup-plugin-commonjs';

rollup({
  entry: 'main.js',
  plugins: [
    nodeResolve({ jsnext: true, main: true }),
    commonjs()
  ]
}).then(bundle => bundle.write({ 
  dest: 'bundle.js', 
  moduleName: 'MyModule',
  format: 'iife' 
})).catch(err => console.log(err.stack));

License

MIT

Related Repositories

angular-froala-wysiwyg

angular-froala-wysiwyg

Angular 2 and Angular 4 plugin for Froala WYSIWYG HTML Rich Text Editor. ...

rollup-plugin-commonjs

rollup-plugin-commonjs

Convert CommonJS modules to ES2015 ...

rollup-plugin-includepaths

rollup-plugin-includepaths

Rollup plugin to allow relative include paths in project files ...

rollup-plugin-aot

rollup-plugin-aot

[Work In Progress] AoT compilation plugin for Rollup ...

angular-gulp-starter

angular-gulp-starter

Simple dev/prod build for Angular (2+) using gulp, systemjs, rollup, ngc (AOT), ...


Top Contributors

Rich-Harris TrySound eventualbuddha lammas joeldenning maranomynet nolanlawson

Releases

-   v2.0.0 zip tar
-   v1.7.3 zip tar
-   v1.7.2 zip tar
-   v1.7.1 zip tar
-   v1.7.0 zip tar
-   v1.6.0 zip tar
-   v1.5.0 zip tar
-   v1.4.0 zip tar
-   v1.3.0 zip tar
-   v1.2.1 zip tar
-   v1.2.0 zip tar
-   v1.1.0 zip tar
-   v1.0.0 zip tar
-   v0.1.0 zip tar