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

babel-plugin-transform-imports

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-imports

Transforms member style imports (import {x} from 'y') into default style imports (import x from 'y/lib/x')

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
220K
increased by3.54%
Maintainers
1
Weekly downloads
 
Created

What is babel-plugin-transform-imports?

babel-plugin-transform-imports is a Babel plugin that allows you to transform import statements in your JavaScript code. This can be useful for optimizing bundle sizes by enabling tree-shaking, aliasing imports, or converting import paths.

What are babel-plugin-transform-imports's main functionalities?

Tree-shaking

This feature allows you to import only the parts of a library that you need, which can significantly reduce the size of your JavaScript bundle. In this example, importing from 'lodash' will be transformed to import only the specific lodash function, preventing full library imports.

{
  "plugins": [
    [
      "transform-imports",
      {
        "lodash": {
          "transform": "lodash/${member}",
          "preventFullImport": true
        }
      }
    ]
  ]
}

Aliasing Imports

This feature allows you to alias import paths, making it easier to manage and refactor your code. In this example, importing from 'my-library' will be transformed to import from 'my-library/dist/${member}', allowing for more flexible and maintainable import paths.

{
  "plugins": [
    [
      "transform-imports",
      {
        "my-library": {
          "transform": "my-library/dist/${member}",
          "preventFullImport": true
        }
      }
    ]
  ]
}

Custom Import Paths

This feature allows you to define custom import paths for your modules. In this example, importing from 'components' will be transformed to import from './src/components/${member}', making it easier to manage and organize your project structure.

{
  "plugins": [
    [
      "transform-imports",
      {
        "components": {
          "transform": "./src/components/${member}",
          "preventFullImport": true
        }
      }
    ]
  ]
}

Other packages similar to babel-plugin-transform-imports

Keywords

FAQs

Package last updated on 01 Jul 2019

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