CG Bundler ๐ง
A powerful Rust code bundler that combines multiple source files into a single, optimized file for competitive programming and code distribution.
๐ Documentation | ๐ Getting Started | ๐ก Examples | ๐ค Contributing
Quick use
With cargo :
Without cargo :
โจ Features
- ๐ Fast bundling - Efficiently combines Rust projects into single files
- ๐ Smart module expansion - Automatically resolves and inlines module dependencies
- ๐งน Code optimization - Removes tests, documentation, and unused code
- ๐๏ธ Configurable transformation - Customize what gets included/excluded
- ๐ฆ Cargo integration - Works seamlessly with standard Cargo projects
- ๐ง CLI & Library - Use as command-line tool or integrate into your workflow
- โก Minification - Optional code minification for size optimization
- ๐ก๏ธ Error handling - Comprehensive error reporting with context
- ๐ Watch mode - NEW Automatic rebuilding on file changes for live development
๐ Getting Started
Installation
From Crates.io (Recommended)
From Source
Quick Start
Command Line Usage
# Bundle current directory
# Bundle specific project
# Output to file
# Minify output
# Keep documentation and tests
# NEW: Watch mode for live development
# Watch with verbose output and fast response
๐ Requirements
- Rust 1.75.0 or later
- Cargo (comes with Rust)
- Compatible with all Rust editions (2015, 2018, 2021)
๐๏ธ CLI Options
| Option | Short | Description |
|---|---|---|
--output |
-o |
Output file path (stdout if not specified) |
--keep-tests |
Keep test code in the bundled output | |
--keep-docs |
Keep documentation comments | |
--no-expand-modules |
Disable module expansion | |
--pretty |
Pretty print the output (format with rustfmt) | |
--minify |
-m |
Minify the output to a single line |
--m2 |
Aggressive minify with whitespace replacements | |
--verbose |
-v |
Verbose output |
--validate |
Validate project can be bundled without errors | |
--info |
Show project structure information | |
--watch |
-w |
NEW Watch for file changes and rebuild automatically |
--src-dir |
Source directory to watch (default: src) | |
--debounce |
Debounce delay in milliseconds (default: 500) | |
--help |
-h |
Print help information |
--version |
-V |
Print version information |
๐ก Examples
Basic Project Structure
my_project/
โโโ Cargo.toml
โโโ src/
โ โโโ main.rs
โ โโโ lib.rs # Optional
โ โโโ utils.rs
โ โโโ game/
โ โ โโโ mod.rs
โ โ โโโ engine.rs
โ โโโ ai/
โ โโโ mod.rs
โ โโโ strategy.rs
Input: Modular Code
// src/main.rs
use GameEngine;
use Strategy;
// src/game/mod.rs
pub use GameEngine;
Output: Bundled Code
// All modules expanded and combined
use GameEngine;
use Strategy;
๐ค Contributing
We welcome contributions! Here's how to get started:
Development Setup
# Clone the repository
# Install dependencies and build
# Run tests
# Check formatting and linting
Reporting Issues
Found a bug? Have a feature request? Please create an issue with:
- Clear description of the problem/feature
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Your environment (OS, Rust version, etc.)
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 CG Bundler Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Made with โค๏ธ by the Rust community
โญ Star us on GitHub | ๐ Report Bug | ๐ก Request Feature