obfus.link

Tree-Shaking Analyzer detects dead exports in ESM or CJS modules and estimates the KB impact per dead export. It generates a ready-to-paste package.json sideEffects field with per-file reasoning, outputs an optimized barrel file as a drop-in replacement, and renders a Mermaid dependency graph with dead paths highlighted. Five outputs in one call.

Tier 3analyzers✓ TDD Verified

Tree-Shaking Analyzer

Find dead exports, estimate bundle savings, generate sideEffects field

How to use

  1. Paste module sourceDrop in the entry file or barrel index of a module — what you ship in package.json main or exports.
  2. Select module formatChoose esm for ES modules with import/export. Choose cjs for require/module.exports.
  3. Specify entry exports (optional)List the exports actually consumed by your application. Everything else is marked as dead candidate.
  4. Enable optional outputsToggle estimateBundleSize, generateSideEffects, generateBarrel, and outputGraph for the outputs you need.
  5. Analyze and actReview the bundleSizeReport, paste the sideEffectsField into package.json, and replace your barrel with the generated one.
Read technical article

MCP / API

Call tree_shaking_analyzer directly from any MCP-compatible agent:

// MCP TypeScript SDK
const result = await client.callTool({
  name: "tree_shaking_analyzer",
  arguments: {
    "code": "...",
    "format": "esm"
  }
});

// curl
curl -X POST https://obfus.link/mcp \
  -H "Authorization: Bearer <SPT>" \
  -H "Content-Type: application/json" \
  -d '{"method":"tools/call","params":{"name":"tree_shaking_analyzer","arguments":{"code":"...","format":"esm"}}}'

Related tools

Var Name Mangler
Obfuscate variable names in JS, TS, and Python with Devcore mode
JSON to Zod
Generate Zod schemas with JSDoc and branded types from any JSON
cURL to Fetch
Convert curl commands to fetch, axios, got, ky, or node-fetch

FAQ

Why does ESM tree-shake better than CJS?

ESM imports are static (declared at module scope, resolved at parse time), so bundlers can safely eliminate unused exports. CJS require() is dynamic and may have side effects, so bundlers must conservatively include the whole module. The analyzer reports both formats but CJS rarely benefits from tree-shaking in real bundlers.

What does Entry Simulation mean?

When you provide entryExports — the exports your app actually consumes — the analyzer marks every other export as a dead-code candidate. This turns a static export report into an actionable removal list specific to your usage, not just "what looks unused."

How accurate is the bundle size estimate?

The estimator computes the gzipped byte size each dead export contributes to a typical Webpack or Vite bundle, accounting for shared imports between exports. It is a conservative estimate (real bundlers may eliminate slightly more), but the relative ranking of exports by KB impact is reliable for prioritization.

What does the package.json sideEffects field actually do?

It tells bundlers which files in a package have import-time side effects and must be retained even if no exports are used. Setting sideEffects: false unlocks aggressive tree-shaking. Setting it to a glob array preserves specific files. Getting this wrong silently breaks either tree-shaking or runtime behavior — the generator gets it right.

Can I use this tool via the MCP API?

Yes. The tool is registered on the obfus.link MCP server at https://obfus.link/mcp. Call it from any MCP-compatible agent with a Shared Payment Token. The MCP tool name matches the snake_case slug shown in the integration snippet.