
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
babel-plugin-import-expander
Advanced tools
Expand multiple members `import` to specific module `import`
Expand multiple members import to specific module import, mainly for performance concerns.
import { A, B, C as D } from '../components';
import A from '../components/A/A';
import B from '../components/B/B';
import D from '../components/C/C';
$ npm install babel-plugin-import-expander --save-dev
.babelrc (Recommended){
"plugins": [
["import-expander", {
"rules": {
"condition": "^(\\.|\\/).*\\/components$",
"template": "{source}/{name}/{name}"
}
}]
]
}
rules
Options can be one object or a list of objects, each object has two properties:
condition
One or multiple string format regular expressions, if the source of ImportDeclaration matches any of them, it will be replaced by the following template.
template
Used to replace hit source with a simple variable placeholder presentation. There are mainly two variable placeholders: {source} represents the source of ImportDeclaration, and {name} represents imported name.
require('babel-core').transform('code', {
plugins: ['import-expander', {
rules: {
condition: '^(\\.|\\/).*\\/components$',
template: '{source}/{name}/{name}'
}
}],
});
FAQs
Expand multiple members `import` to specific module `import`
The npm package babel-plugin-import-expander receives a total of 1 weekly downloads. As such, babel-plugin-import-expander popularity was classified as not popular.
We found that babel-plugin-import-expander 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.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.