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-transform-remove-imports
Advanced tools
Remove the specified import declaration when you use the babel transform to build the package.
Modular import plugin for babel for server-side rendering. Also works for cjs to delete imported CSS to avoid compilation errors..
npm install babel-plugin-transform-remove-imports --save-dev
Via .babelrc
or babel-loader
.
{
"plugins": [
[
"babel-plugin-transform-remove-imports", {
"test": "\\.(less|css)$"
}
]
]
}
// Input Code
import './index.less';
import './index.main.less';
import { Button } from 'uiw';
import { Select } from '@uiw/core';
// Output ↓ ↓ ↓ ↓ ↓ ↓
import { Button } from 'uiw';
import { Select } from '@uiw/core';
Output Result
- import './index.less';
- import './index.main.less';
import { Button } from 'uiw';
import { Select } from '@uiw/core';
test: RegExp | string | (RegExp | string)[]
A regular expression to match the imports that will be removed. It could be a string or a RegExp object. You could also pass an array here.
removeAll: boolean
Deletes all imports.
remove?: 'effects'
Removing only side effects imports,Used with the test
option. #3
// Input Code
import 'foo';
import Foo from 'foo';
// Output Code ↓ ↓ ↓ ↓ ↓ ↓
import Foo from 'foo';
import plugin from 'babel-plugin-transform-remove-imports'
import { transform } from 'babel-core'
function replace (code) {
return transform(code, {
babelrc: false,
plugins: [
[plugin, { test: /\.(less|css)$/ }]
],
}).code;
}
replace("import './index.main.less';import { Button } from 'uiw';")
//=> "import { Button } from 'uiw';"
MIT © Kenny Wong
FAQs
Remove the specified import declaration when you use the babel transform to build the package.
The npm package babel-plugin-transform-remove-imports receives a total of 19,316 weekly downloads. As such, babel-plugin-transform-remove-imports popularity was classified as popular.
We found that babel-plugin-transform-remove-imports demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.