Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-auto-import

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-auto-import

Auto imports

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-10.63%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-auto-import

Convert global variables to import statements

Examples

Example 1

.babelrc

{
  "plugins": [[
    "auto-import", {
      "declarations": [
        { "default": "React", "path": "react" }
      ]
    }
  ]]
}

In

React.createElement("div", null, []);

Out

import React from "react";

React.createElement("div", null, []);

Example 2

.babelrc

{
  "plugins": [[
    "auto-import", {
      "declarations": [
        { "default": "React", "members": ["Component"], "path": "react" }
      ]
    }
  ]]
}

In

class MyComponent extends Component { }

Out

import { Component } from "react";

class MyComponent extends Component { }

Example 3

Suitable for polyfilling browser built-ins (eg. window.fetch)

.babelrc

{
  "plugins": [[
    "auto-import", {
      "declarations": [
        { "anonymous": ["fetch"], "path": "whatwg-fetch" }
      ]
    }
  ]]
}

In

fetch("http://example.com/qwe");

Out

import "whatwg-fetch";

fetch("http://example.com/qwe");

Keywords

FAQs

Package last updated on 27 Sep 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc