Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
babel-dead-code-elimination
Advanced tools
Composable primitives for dead code elimination in Babel
Composable primitives for dead code elimination in Babel
This package is not a Babel plugin, but rather a set of composable primitives to author your own Babel transforms and plugins.
npm install babel-dead-code-elimination
Eliminates unused code from the Babel AST by repeatedly removing unreferenced identifiers.
import { parse } from "@babel/parser"
import generate from "@babel/generator"
import { deadCodeElimination } from "babel-dead-code-elimination"
let source = "..."
let ast = parse(source, { sourceType: "module" })
deadCodeElimination(ast)
let result = generate(ast).code
Find identifiers that are currently referenced in the Babel AST.
Useful for limiting deadCodeElimination
to only eliminate newly unreferenced identifiers,
as a best effort to preserve any intentional side-effects in the source.
import { parse } from "@babel/parser"
import generate from "@babel/generator"
import traverse from "@babel/traverse"
import {
deadCodeElimination,
findReferencedIdentifiers,
} from "babel-dead-code-elimination"
let source = "..."
let ast = parse(source, { sourceType: "module" })
let referenced = findReferencedIdentifiers(ast)
traverse(ast, {
/* ... your custom transform goes here ... */
})
deadCodeElimination(ast, referenced)
let result = generate(ast).code
Credit to Jason Miller for the initial implementation. Thanks to these projects for exploring dead code elimination:
FAQs
Composable primitives for dead code elimination in Babel
We found that babel-dead-code-elimination 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.