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

babel-plugin-import

Package Overview
Dependencies
Maintainers
5
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import

Component modular import plugin for babel.

  • 1.13.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created

What is babel-plugin-import?

babel-plugin-import is a Babel plugin for modular import of components, enabling on-demand loading of specific parts of a library. This can help reduce bundle sizes by only including the necessary parts of a library in the final build.

What are babel-plugin-import's main functionalities?

Importing specific components

This feature allows you to import specific components from a library like 'antd' without importing the entire library. The configuration in babel.config.js specifies the library name, directory, and style options. The import statement in the JavaScript file then only includes the 'Button' component.

/* Babel configuration (babel.config.js) */
{
  "plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "libraryDirectory": "es",
        "style": "css"
      }
    ]
  ]
}

/* Usage in a JavaScript file */
import { Button } from 'antd';

Customizing import paths

This feature allows you to customize the import paths for libraries like 'lodash'. The configuration in babel.config.js specifies the library name and options like 'camel2DashComponentName' to control the import path format. The import statement in the JavaScript file then only includes the 'debounce' function.

/* Babel configuration (babel.config.js) */
{
  "plugins": [
    [
      "import",
      {
        "libraryName": "lodash",
        "libraryDirectory": "",
        "camel2DashComponentName": false
      },
      "lodash"
    ]
  ]
}

/* Usage in a JavaScript file */
import { debounce } from 'lodash';

Other packages similar to babel-plugin-import

Keywords

FAQs

Package last updated on 26 Jul 2023

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