odoo-bundler is a high-performance Rust tool designed to accelerate Odoo asset processing. It provides functionality to resolve JavaScript imports, bundle XML templates, and generate complete asset bundles for Odoo's frontend.
The project is designed to be used in two ways:
- As a CLI tool for standalone usage or shell integration.
- As a Python extension for direct integration into Python-based Odoo build workflows (using PyO3).
- Fast JS Parsing: Rapidly scans JavaScript files to resolve and validate imports.
- TypeScript Support: Automatically transpiles TypeScript files (
.ts) to JavaScript during bundling. - XML Template Bundling: Compiles Odoo QWeb XML templates into JavaScript bundles.
- Asset Bundling: Combines JS entry points and XML templates into a single optimized output.
- Optimization Levels: Supports multiple levels of minification (None, Whitespace, Full) using
oxc_minifier. - Dual API: Access the same high-performance core via CLI or Python.
- Rust (latest stable)
- Python 3.7+ (for Python bindings)
cargo build --release
# The binary will be available at target/release/odoo-bundlerThis project uses maturin for building Python extensions.
# Install maturin
pip install maturin
# Build and install into current environment
maturin develop --releaseThe CLI tool expects file lists to be provided as text files (one path per line).
# Create a full bundle (JS + XML)
# Usage: odoo-bundler bundle <bundle_name> <file_list> [options]
# Default behavior: writes to out/bundle/my_bundle.js
odoo-bundler bundle my_bundle files.txt
# Optimization options:
odoo-bundler bundle my_bundle files.txt --minify-level full # Max compression
odoo-bundler bundle my_bundle files.txt --minify-level none # No minification
odoo-bundler bundle my_bundle files.txt --sourcemap # Enable source maps
# Bundle with output to stdout
odoo-bundler bundle my_bundle files.txt --output-stdout
# Bundle with custom output path
odoo-bundler bundle my_bundle files.txt --output custom_path.js
# Bundle with timing metrics to stdout (default if --time is used)
odoo-bundler bundle my_bundle files.txt --timeimport odoo_bundler
# Create full bundle
# files is a mixed list of JS and XML paths
files = ["static/src/file1.js", "static/src/template1.xml"]
# Default bundle (Whitespace minification, no map)
full_bundle = odoo_bundler.bundle("my.bundle", files)
# Custom bundle with specific options
# minify_level options: "none", "whitespace", "full"
custom_bundle = odoo_bundler.bundle(
"my.bundle",
files,
minify_level="none",
sourcemap=True
)Run tests:
cargo testRun Python integration tests:
# Ensure the extension is installed first
maturin develop
python -m pytest python_tests/