rollup-plugin-inject
    Overview
    Documentation
    Tutorials
    Insights
    Code
    Dependencies
    Contributors
    Jobs

rollup-plugin-inject

Scan modules for global variables and inject `import` statements where necessary

3.0.1  •  Updated 8 months ago  •  by rollup  •  MIT License

Scan modules for global variables and inject import statements where necessary

Installation

npm install --save-dev rollup-plugin-inject

Usage

import { rollup } from 'rollup';
import inject from 'rollup-plugin-inject';

rollup({
  entry: 'main.js',
  plugins: [
    inject({
      // control which files this plugin applies to
      // with include/exclude
      include: '**/*.js',
      exclude: 'node_modules/**',

      /* all other options are treated as modules...*/

      // use the default – i.e. insert
      // import $ from 'jquery'
      $: 'jquery',

      // use a named export – i.e. insert
      // import { Promise } from 'es6-promise'
      Promise: [ 'es6-promise', 'Promise' ],

      // use a namespace import – i.e. insert
      // import * as fs from 'fs'
      fs: [ 'fs', '*' ],

      // use a local module instead of a third-party one
      'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),

      /* ...but if you want to be careful about separating modules
         from other options, supply `options.modules` instead */

      modules: {
        $: 'jquery',
        Promise: [ 'es6-promise', 'Promise' ],
        'Object.assign': path.resolve( 'src/helpers/object-assign.js' )
      }
    })
  ]
}).then(...)

Popularity

Weekly Downloads
10.7K
Stars
73

Maintenance

Development

Last ver 8 months ago
Created 4 years ago
Last commit 4 months ago
19 days between commits

Technology

Node version: 10.16.0
20.2K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

13 contributors
Rich-Harris
Maintainer, 36 commits, 4 merges, 2 PRs
Denis Bardadym
Maintainer, 23 commits, 4 merges, 1 PRs
Lukas Taegert
Maintainer, 7 commits, 1 merges
Works at TNG Technology Consulting GmbH
Manu Mtz.-Almeida
5 commits, 1 PRs
Works at Ionic Framework Team
shellscape
Maintainer, 3 commits
Tyler Johnson
2 commits, 1 PRs
Works at pagedip

Tags

rollup
rollup-plugin
es2015
npm
modules
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.