Skip to content

Goaman/odoo_bundler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

odoo-bundler

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:

  1. As a CLI tool for standalone usage or shell integration.
  2. As a Python extension for direct integration into Python-based Odoo build workflows (using PyO3).

Features

  • 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.

Installation

Prerequisites

  • Rust (latest stable)
  • Python 3.7+ (for Python bindings)

Building the CLI

cargo build --release
# The binary will be available at target/release/odoo-bundler

Installing the Python Library

This project uses maturin for building Python extensions.

# Install maturin
pip install maturin

# Build and install into current environment
maturin develop --release

Usage

CLI

The 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 --time

Python

import 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
)

Development

Run tests:

cargo test

Run Python integration tests:

# Ensure the extension is installed first
maturin develop
python -m pytest python_tests/

About

odoo_bundler

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors