oxphobia
v0.0.2
Published
Calculate minified & gzipped bundle size via JSDelivr + Oxc (Parser/Minifier)
Readme
📦 Oxphobia
Oxphobia is an ultra-fast JavaScript bundle size calculator powered by Oxc (The Oxide JavaScript Tools).
By leveraging the Rust-based oxc-parser and oxc-minify, it performs high-speed dependency analysis and minification to instantly measure the "Minified + Gzipped" size of npm packages or local projects.
✨ Features
- 🚀 Blazing Fast: Powered by the Rust-based Oxc toolchain for incredibly quick parsing and compression.
- ☁️ npm Package Support: Recursively fetches and calculates the size of specified packages via jsDelivr .
- 📂 Local Project Support: Run it at your project root to automatically detect entry points and estimate the total size including dependencies.
- 🌳 Simple Tree-Shaking: Analyzes conditional branches based on
process.env.NODE_ENVto exclude unnecessary code from the bundle.
📦 Installation
You can run it directly via npx or install it globally.
# Run directly
npx oxphobia [package-name]
pnpm dlx oxphobia [package-name]
yarn dlx oxphobia [package-name]
# or
dx npm:oxphobia [package-name]
# or
bunx oxphobia [package-name]Or install globally:
npm install -g oxphobia🚀 Usage
1. Measure npm package size
Specify a package name to fetch sources from the CDN (jsDelivr) and calculate its size.
npx oxphobia react
npx oxphobia lodash-es
npx oxphobia three2. Measure local project size
Run without arguments to read the package.json in the current directory. It will identify the entry point from the main, module, or exports fields for analysis.
cd my-awesome-project
npx oxphobiaExample Output
📦 Analyzing Package: react
📥 Downloaded: https://cdn.jsdelivr.net/npm/[email protected]/index.js
🔎 Dependencies: ./cjs/react.production.min.js
📥 Downloaded: https://cdn.jsdelivr.net/npm/[email protected]/cjs/react.production.min.js
...
✅ Dependency resolution complete.
⏳ Minifying with Oxc Minify...
========================================
📊 Result for "react"
========================================
Files count : 2
Minified size : 6.42 KB (6,572 bytes)
Gzipped size : 2.75 KB (2,814 bytes)
========================================🛠️ How It Works
- Parsing: Uses
oxc-parserto build an AST (Abstract Syntax Tree) and extracts dependencies fromimport,require, andexportstatements. - Resolution:
- Local files are read from the file system.
- External packages are resolved and downloaded via the jsDelivr API.
- Bundling: Combines dependencies in-memory.
- Minification: Compresses the code (Mangle & Compress) using
oxc-minify. - Measuring: Compresses the minified code using Node.js
zlib(Gzip) and calculates the final byte count.
⚠️ Limitations
- Non-JS assets such as CSS and images are ignored.
- Advanced bundler configurations (e.g., Webpack/Rollup/Vite plugins) are not supported. It only tracks pure JS/ESM dependencies.
💻 Requirements
- Node.js >= 18.12.0
🤝 Contributing
Pull requests are welcome!
📄 License
MIT
