Socket
Socket
Sign inDemoInstall

rollup-plugin-inject

Package Overview
Dependencies
4
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rollup-plugin-inject

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


Version published
Weekly downloads
547K
decreased by-23.09%
Maintainers
4
Install size
662 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 29 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc