Skip to content

Commit

Permalink
update transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 27, 2024
1 parent 4a65f91 commit 2e718cd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/docs/guide/usage/transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Transforming TypeScript and React JSX files to ESNext.
- [TypeScript Isolated Declarations Emit](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#isolated-declarations) without using the TypeScript compiler.

## Installation
Expand All @@ -16,6 +17,24 @@ Use the umbrella crate [oxc][url-oxc-crate] with the `transformer` feature.

Rust usage example can be found [here](https://github.com/oxc-project/oxc/blob/main/crates/oxc_transformer/examples/transformer.rs).

## API Example

```javascript
import { transform } from "oxc-transform";
const transformed = transform(filePath, sourceCode, {
typescript: {
onlyRemoveTypeImports: true,
declaration: { stripInternal: true },
},
});
await fs.writeFile("out.js", transformed.code);
await fs.writeFile("out.d.ts", transformed.declaration);
```

## Isolated Declarations

- [`unplugin-isolated-decl`](https://github.com/unplugin/unplugin-isolated-decl)

<!-- Links -->

[url-oxc-crate]: https://docs.rs/oxc
Expand Down

0 comments on commit 2e718cd

Please sign in to comment.