New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-rename-import

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-rename-import

Replace import sources

  • 1.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66K
increased by6.03%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-rename-import Build Status npm

replace import sources

Install

$ npm install --save babel-plugin-transform-rename-import

Usage

import visitor from 'babel-plugin-transform-rename-import'
import traverse from 'babel-traverse'
import generate from 'babel-generator'
import { transform } from 'babel-core'

function replace (code, original, replacement) {
  const { ast } = transform(code)
  traverse(ast, visitor({ replacement, original }).visitor)
  return generate(ast, {}, code).code.trim()
}

replace("require('foo')", 'foo', 'bar')
//=> "require('bar');"

replace("import foo from 'foo'", 'foo', 'bar')
//=> "import foo from 'bar';"

replace("require('foo/thingy')", 'foo', 'bar')
//=> "require('bar/thingy');"

License

MIT © Sigurd Fosseng

FAQs

Package last updated on 15 Aug 2016

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