
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
babel-plugin-import-rename
Advanced tools
Rename import sources with a RegExp like a boss.
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 }; }
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"
}
]]
}
require('babel-core').transform('code', {
plugins: [[
'import-rename', {
'regex1': 'replacement1',
'regex2': 'replacement2'
}
]]
})
FAQs
Rename import sources
We found that babel-plugin-import-rename demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.