πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
DemoInstallSign in
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
Version published
Weekly downloads
445K
13.13%
Maintainers
5
Weekly downloads
Β 
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

babel-plugin

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