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

babel-plugin-import-resolver

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import-resolver

Resolve multiple members import to specific module import

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-import-resolver

Build Status

Resolve multiple members import to specific module import, mainly for leverage the performance of importing a couple of react components.

Example

In
import { A, B, C as D } from '../components';
Out
import A from '../components/A/A';
import B from '../components/B/B';
import D from '../components/C/C';

Installation

$ npm install babel-plugin-import-resolver

Usage

{
  "plugins": [
    ["import-resolver", {
      "condition": "^(\\.|\\/).*\\/components$",
      "template": "{source}/{name}/{name}"
    }]
  ]
}

There are two options:

  • condition (String or [String])

    One or multiple string format regular expressions, if the source of ImportDeclaration matches any of them, it will be replaced by the following template.

  • template (String)

    Used to replace hit source with a simple variable placeholder presentation. There are mainly two variable placeholders: {source} represents the source of ImportDeclaration, and {name} represents imported name.

Via Node API
require('babel-core').transform('code', {
  plugins: ['import-resolver', {
    condition: '^(\\.|\\/).*\\/components$',
    template: '{source}/{name}/{name}',
  }],
});

Keywords

FAQs

Package last updated on 20 Jan 2017

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