Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rollup-plugin-inject

rollup3.5mMITdeprecated3.0.2

This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.

Scan modules for global variables and inject import statements where necessary

rollup, rollup-plugin, es2015, npm, modules

readme

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

changelog

rollup-plugin-inject

3.0.1

  • Generate sourcemap when sourcemap enabled

3.0.0

  • Remove node v6 from support
  • Use modern js

2.1.0

  • Update all dependencies (#15)

2.0.0

  • Work with all file extensions, not just .js (unless otherwise specified via options.include and options.exclude) (#6)
  • Allow * imports (#9)
  • Ignore replacements that are superseded (e.g. if Buffer.isBuffer is replaced, ignore Buffer replacement) (#10)

1.4.1

  • Return a name

1.4.0

  • Use string.search instead of regex.test to avoid state-related mishaps (#5)
  • Prevent self-importing module bug

1.3.0

  • Windows support (#2)
  • Node 0.12 support

1.2.0

  • Generate sourcemaps by default

1.1.1

  • Use modules option

1.1.0

  • Handle shorthand properties

1.0.0

  • First release