Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
  • Loading branch information
Boshen and overlookmotel authored Sep 28, 2024
1 parent 9d09250 commit 3bfb15a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/blog/2024-09-29-transformer-alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In this alpha stage, we recommend to experiment these features to significantly

### [`oxc-transform`](https://www.npmjs.com/package/oxc-transform) npm package

vue.js is [experimenting](https://github.com/vuejs/core/blob/0895b2624b707ea1e75c41f2e1f75388e7a6f101/scripts/build-types.js#L20) with isolated declarations in their build pipeline.
Vue.js is [experimenting](https://github.com/vuejs/core/blob/0895b2624b707ea1e75c41f2e1f75388e7a6f101/scripts/build-types.js#L20) with isolated declarations in their build pipeline.

```javascript
import { isolatedDeclaration } from "oxc-transform";
Expand All @@ -39,7 +39,7 @@ const dts = isolatedDeclaration(filename, ts);
[@lukeed](https://github.com/lukeed) and [@maraisr](https://github.com/maraisr) are utilizing `oxc-transform`
for their packages
[`empathic`](https://github.com/lukeed/empathic) and [`dldr`](https://github.com/maraisr/dldr)
to transform and generate dts [in a single step](https://github.com/lukeed/empathic/blob/b83a360ff55051590dec19aa913cd12da97fa3f8/scripts/build.ts#L45-L52).
to transform and generate `.d.ts` [in a single step](https://github.com/lukeed/empathic/blob/b83a360ff55051590dec19aa913cd12da97fa3f8/scripts/build.ts#L45-L52).

The following example demonstrates emitting `.js` and `.d.ts` in a single transformation step:

Expand All @@ -61,25 +61,25 @@ await fs.writeFile("out.d.ts", transformed.declaration);

[@sxzz](https://github.com/sxzz) [reports](https://x.com/sanxiaozhizi/status/1821320327231893600) their `.d.ts` generation time is reduced from 76s to 16s.

### Bazel Build at [Airtable](https://github.com/Airtable)
### Bazel build at [Airtable](https://github.com/Airtable)

[@michaelm](https://github.com/MichaelMitchell-at) from [Airtable](https://github.com/Airtable)
is integrating oxc's isolated declarations dts emit in their CI pipeline within their [bazel build](https://github.com/aspect-build/rules_ts/pull/697).
is integrating Oxc's isolated declarations `.d.ts` emit in their CI pipeline within their [Bazel build](https://github.com/aspect-build/rules_ts/pull/697).

### Rust [`oxc_transformer`](https://crates.io/crates/oxc_transformer) crate

The [Rolldown](https://rolldown.rs) bundler uses the `oxc_transformer` crate [directly](https://github.com/rolldown/rolldown/blob/3213e8fdb9e25f29295b6ec0d92fcc2ce03ce396/crates/rolldown/src/utils/pre_process_ecma_ast.rs#L67-L75).
[Rolldown](https://rolldown.rs) bundler uses the `oxc_transformer` Rust crate [directly](https://github.com/rolldown/rolldown/blob/3213e8fdb9e25f29295b6ec0d92fcc2ce03ce396/crates/rolldown/src/utils/pre_process_ecma_ast.rs#L67-L75).

## [Benchmark Results](https://github.com/oxc-project/bench-transformer)

On [GitHub Actions ubuntu-latest](https://github.com/oxc-project/bench-transformer/actions/workflows/ci.yml):

Using the following files:

- [cal.com - UserSettings.tsx](https://github.com/calcom/cal.com/blob/20729b3a4e62c52f49419d2c3b30225f0c7a5936/apps/web/components/getting-started/steps-views/UserSettings.tsx) - a typical 124 lines of tsx code.
- [TypeScript - parser.ts](https://github.com/microsoft/TypeScript/blob/3ad0f752482f5e846dc35a69572ccb43311826c0/src/compiler/parser.ts) - an atypical large file with 10777 lines.
- [vuejs - renderer.ts](https://github.com/vuejs/core/blob/cb34b28a4a9bf868be4785b001c526163eda342e/packages/runtime-core/src/renderer.ts) - a large library file with 2550 lines.
- [AFFiNE - table.tsx](https://github.com/toeverything/AFFiNE/blob/a9b29d24f1f6e5563e43a11b5cbcfb30c9981d25/packages/frontend/core/src/components/affine/page-properties/table.tsx) - a tsx file with 1118 lines.
- [cal.com - UserSettings.tsx](https://github.com/calcom/cal.com/blob/20729b3a4e62c52f49419d2c3b30225f0c7a5936/apps/web/components/getting-started/steps-views/UserSettings.tsx) - typical TSX file with 124 lines of code.
- [TypeScript - parser.ts](https://github.com/microsoft/TypeScript/blob/3ad0f752482f5e846dc35a69572ccb43311826c0/src/compiler/parser.ts) - an atypically large TS file with 10777 lines.
- [Vue.js - renderer.ts](https://github.com/vuejs/core/blob/cb34b28a4a9bf868be4785b001c526163eda342e/packages/runtime-core/src/renderer.ts) - a large library file with 2550 lines.
- [AFFiNE - table.tsx](https://github.com/toeverything/AFFiNE/blob/a9b29d24f1f6e5563e43a11b5cbcfb30c9981d25/packages/frontend/core/src/components/affine/page-properties/table.tsx) - TSX file with 1118 lines.

### Transform

Expand All @@ -101,7 +101,7 @@ oxc > table.tsx (1.0 ms)
59.54x faster than babel (58.5 ms)
```

Oxc is 4x faster than swc, and 40x faster than Babel.
Oxc is 4x faster than SWC, and 40x faster than Babel.

### Isolated Declarations

Expand All @@ -119,11 +119,11 @@ oxc > table.tsx (1.7 ms)
7.24x faster than tsc (22.0 ms)
```

Compared to tsc, oxc is 45x faster on small files, and 20x faster on larger files.
Compared to `tsc`, Oxc is 45x faster on small files, 20x faster on larger files.

## Package size

For package download size, oxc downloads two packages for a total of 2MB.
Oxc downloads only 2 npm packages, a total of 2 MB.

| Package | Size |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
Expand All @@ -135,7 +135,7 @@ For package download size, oxc downloads two packages for a total of 2MB.

Oxc uses less memory.

On `parser.ts` (10777 lines) by using `/usr/bin/time -alh node`:
Memory usage transforming `parser.ts` (10777 lines) - measured using `/usr/bin/time -alh node`:

| | Max RSS |
| ----- | ------- |
Expand Down

0 comments on commit 3bfb15a

Please sign in to comment.