oxc_transformer_plugins

Crates.iooxc_transformer_plugins
lib.rsoxc_transformer_plugins
version0.83.0
created_at2025-04-25 08:48:03.548691+00
updated_at2025-08-29 06:55:52.285495+00
descriptionA collection of JavaScript tools written in Rust.
homepagehttps://oxc.rs
repositoryhttps://github.com/oxc-project/oxc
max_upload_size
id1648699
size153,442
Boshen (Boshen)

documentation

README

Oxc Transformer Plugins

Specialized transformation plugins for common JavaScript and TypeScript patterns.

Overview

This crate provides specific transformation plugins that can be used independently or as part of the broader oxc transformation pipeline. These plugins handle common transformation needs like global variable injection and module format conversion.

Key Features

  • Global variable injection: Add global variables to modules
  • Module runner transforms: Transform modules for different execution environments
  • Global defines replacement: Replace compile-time constants
  • Composable plugins: Use individually or combine multiple plugins

Architecture

Plugin System

Each plugin implements the transformation logic for a specific use case:

  • Focused responsibility: Each plugin handles one type of transformation
  • Traverse integration: Uses oxc's traversal system for efficient AST walking
  • Composable: Multiple plugins can be applied in sequence
  • Context-aware: Access to semantic information when needed

Common Use Cases

Build-time Optimizations

  • Dead code elimination: Remove unreachable code paths
  • Constant folding: Replace compile-time constants
  • Environment variables: Inject environment-specific values

Module System Compatibility

  • Polyfill injection: Add necessary polyfills for target environments
  • Global shimming: Provide Node.js globals in browser environments
  • Format conversion: Transform between module formats

Development Tools

  • Debug injection: Add development-time debugging code
  • Hot module replacement: Support for HMR systems
  • Testing utilities: Inject test-specific globals

Integration Points

These plugins integrate with:

  • oxc_transformer: Core transformation infrastructure
  • oxc_traverse: AST traversal and mutation
  • Build tools: Webpack, Vite, Rollup, and other bundlers
  • CLI tools: Direct usage in command-line transformations

The plugin architecture enables extensible, composable transformations while maintaining high performance through oxc's efficient traversal system.

Commit count: 11571

cargo fmt