Transformer
Use transformSync to compile TypeScript, JSX, decorators, modules, and modern ECMAScript syntax directly from source to output code. Import it from @swc-next/core, the focused @swc-next/transformer package, or the initialized browser package.
Transform TypeScript and JSX
Pass filename to infer the parser language and source type automatically. TypeScript and JSX transforms are enabled by default for matching extensions:
Target environments and modules
Lower newer ECMAScript syntax with target, and convert ES modules with module:
target accepts an ES edition ("es2015"–"es2026", "esnext"), a Browserslist query or query list, or an engine version map such as { node: "18" }.
Source maps and diagnostics
Enable sourceMap to generate a JSON source map alongside the transformed code. Syntax and transform diagnostics are returned in diagnostics rather than thrown:
Reference
See the Transformer API for all options, including typescript, jsx, decorators, module, features, assumptions, polyfill, comments, and nested parser / generator settings.