
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
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 0 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
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.