Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
babel-plugin-import-resolver
Advanced tools
Resolve import to specific file.
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-resolver
.babelrc
(Recommended){
"plugins": [
["import-resolver", {
"condition": "^(\\.|\\/).*\\/components$",
"template": "{source}/{name}/{name}"
}]
]
}
There are two options:
condition
(String
or [String]
)
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
(String
)
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-resolver', {
condition: '^(\\.|\\/).*\\/components$', // string format regular expression
template: '{source}/{name}/{name}', // template variables (wrapped in braces) will be replaced
}],
});
FAQs
Resolve multiple members import to specific module import
The npm package babel-plugin-import-resolver receives a total of 24 weekly downloads. As such, babel-plugin-import-resolver popularity was classified as not popular.
We found that babel-plugin-import-resolver 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.