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

babel-plugin-import-rename

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import-rename

Rename import sources

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-5.74%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-import-rename Build Status Dependency Status

Rename import sources with a RegExp like a boss.

Example

Maybe you want to remove .jsx extension from compiled files:

input.js

import Foo from './Foo.jsx'

.babelrc

{
  "presets": ["react", "es2015"],
  "plugins": [
    ["import-rename", {"^(.*)\\.jsx$": "$1"}]
  ]
}

output.js

'use strict';
var _Foo = require('./Foo');
var _Foo2 = _interopRequireDefault(_Foo);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

Usage

Specify sources and replacements as plugin options. Option keys are strings passed directly to the RegExp constructor for matching against import sources in your code. Option values are the replacements.

{
  "plugins": [[
    "import-rename", {
      "regex1": "replacement1",
      "regex2": "replacement2"
    }
  ]]
}

Via Node API

require('babel-core').transform('code', {
  plugins: [[
    'import-rename', {
      'regex1': 'replacement1',
      'regex2': 'replacement2'
    }
  ]]
})

js-standard-style

Keywords

FAQs

Package last updated on 18 May 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