Expand description
TSX to JavaScript transformation logic
This module handles the transformation of TSX/JSX syntax to JavaScript using the Oxc compiler. It supports various JSX pragmas (engine, React-compatible) and handles component wrapping.
§Transformation Process
- Optionally wrap raw TSX in a component function
- Parse TSX into an AST using Oxc parser
- Build semantic information for better transformation
- Apply JSX transformations (convert to function calls)
- Generate JavaScript code with optional minification
- Clean up generated code (remove pure annotations)
§Error Handling
All transformation errors use MdxError for domain-specific error reporting.
Functions§
- create_
transform_ options - Creates transformation options for JSX processing
- transform_
component_ code - Intelligently transforms component code (detects if it’s raw JSX or a function)
- transform_
component_ function - Transforms a full component function definition (already wrapped)
- transform_
tsx_ to_ js - Transforms TSX content to JavaScript using the default configuration
- transform_
tsx_ to_ js_ for_ output - Transforms TSX content to JavaScript for final output (uses
hinstead ofengine.h) - transform_
tsx_ to_ js_ with_ config - Transforms TSX content to JavaScript using the Oxc compiler
- wrap_
in_ component - Wraps TSX content in a React component structure