{"library":"oxc-transform","title":"Oxc Transform Node API","description":"oxc-transform is the Node.js API for Oxc's high-performance JavaScript, TypeScript, and React JSX transformer, which is built in Rust. It provides synchronous (`transformSync`, `isolatedDeclarationSync`) and asynchronous (`transform`, `isolatedDeclaration`) functions for parsing and transforming code. A key feature is its specialized capability for generating TypeScript declaration files (`.d.ts`) with isolated declarations, fully conforming to TypeScript's `--isolatedDeclarations` compiler option. Currently at version 0.126.0, the package maintains a rapid release cadence, reflecting active and continuous development within the broader Oxc project ecosystem. Its primary differentiators include its Rust-native performance, positioning it as a fast and efficient alternative to tools like Babel, and its robust, up-to-date support for modern ECMAScript features, TypeScript syntax, and React JSX out-of-the-box. The library is designed to serve as a foundational, high-performance component for various JavaScript build and tooling pipelines requiring efficient code transformation.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oxc-transform"],"cli":null},"imports":["import { transformSync } from 'oxc-transform';","import { transform } from 'oxc-transform';","import { isolatedDeclarationSync } from 'oxc-transform';","import type { TransformOptions } from 'oxc-transform';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import assert from \"assert\";\nimport { transformSync } from \"oxc-transform\";\n\nconst filename = \"test.ts\";\nconst sourceCode = \"class A<T> { constructor(arg: T) { console.log(arg); } }\";\n\n// Transform TypeScript code to plain JavaScript and generate a declaration file\nconst { code, declaration, errors } = transformSync(filename, sourceCode, {\n  typescript: {\n    declaration: true, // Enable isolated declarations\n    jsxPragma: \"React\",\n    jsxPragmaFrag: \"React.Fragment\"\n  },\n  // Example: Enable more transformations if needed\n  react: {\n    runtime: \"automatic\",\n    development: true\n  }\n});\n\n// Log results for verification\nconsole.log(\"Transformed Code:\\n\", code);\nconsole.log(\"Declaration File:\\n\", declaration);\n\n// Basic assertions\nassert.equal(code.trim(), \"class A { constructor(arg) { console.log(arg); } }\");\nassert.equal(declaration.trim(), \"declare class A<T> {\\n    constructor(arg: T);\\n}\");\nassert.equal(errors.length, 0, `Expected no errors, but got ${errors.length} errors.`);\n\nconsole.log(\"Transformation successful!\");","lang":"typescript","description":"This example demonstrates how to use `transformSync` to transpile TypeScript code to JavaScript and simultaneously generate a `.d.ts` declaration file with isolated declarations, including basic options for JSX and React.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}