rollup-plugin-inject

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

This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
Last updated 9 years ago by rich_harris .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install rollup-plugin-inject 
SYNC missed versions from official npm registry.

rollup-plugin-inject

Scan modules for global variables and inject import statements where necessary

Archived (Migration to Mono-Repo In-Process)

This repository has been archived and is in the process of being migrated to a new monorepo. Please bear with us as we make this transition. More information to follow.

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(...)

Current Tags

  • 3.0.2                                ...           latest (5 years ago)

13 Versions

  • 3.0.2 [deprecated]           ...           5 years ago
  • 3.0.1 [deprecated]           ...           5 years ago
  • 3.0.0 [deprecated]           ...           6 years ago
  • 2.2.0 [deprecated]           ...           6 years ago
  • 2.1.0 [deprecated]           ...           6 years ago
  • 2.0.0 [deprecated]           ...           8 years ago
  • 1.4.1 [deprecated]           ...           9 years ago
  • 1.4.0 [deprecated]           ...           9 years ago
  • 1.3.0 [deprecated]           ...           9 years ago
  • 1.2.0 [deprecated]           ...           9 years ago
  • 1.1.1 [deprecated]           ...           9 years ago
  • 1.1.0 [deprecated]           ...           9 years ago
  • 1.0.0 [deprecated]           ...           9 years ago
Maintainers (1)
Downloads
Total 4
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE