Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
babel-dead-code-elimination
Advanced tools
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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.