Skip to content

Commit

Permalink
refresh + dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 28, 2024
1 parent 4031ed8 commit 1d1517d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
## Summary

* Compared to swc, oxc transformer is 4x faster, uses 20% less memory, and is 35 MB smaller in package size (from swc's 37MB).
* React development + refresh is 7x faster than swc and 75x faster than Babel.
* Compared to babel, oxc transformer is 40x faster, uses 70% less memory, and is 19 MB smaller with 168 npm packages less to install.
<!-- * Compared to tsc's isolated declarations dts emit, oxc is x times faster. -->

## Transform / Transpile

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

React development + refresh is 7x faster than swc and 75x faster Babel.

### GitHub Actions `ubuntu-latest`

```
Expand All @@ -30,20 +33,40 @@ Oxc is 4x faster than swc, and 40x faster than Babel.

```
oxc - src/transform.bench.js > UserSettings.tsx
6.43x faster than swc
67.96x faster than babel
6.90x faster than swc
56.93x faster than babel
oxc - src/transform.bench.js > parser.ts
3.55x faster than swc
44.01x faster than babel
4.01x faster than swc
42.31x faster than babel
oxc - src/transform.bench.js > renderer.ts
3.62x faster than swc
24.58x faster than babel
3.76x faster than swc
27.47x faster than babel
oxc - src/transform.bench.js > table.tsx
4.22x faster than swc
34.35x faster than babel
3.94x faster than swc
33.74x faster than babel
```

#### React Development + Refresh

```
oxc - src/transform.bench.js > UserSettings.tsx
7.16x faster than swc
75.47x faster than babel
oxc - src/transform.bench.js > parser.ts
4.03x faster than swc
51.63x faster than babel
oxc - src/transform.bench.js > renderer.ts
3.86x faster than swc
33.55x faster than babel
oxc - src/transform.bench.js > table.tsx
4.18x faster than swc
45.02x faster than babel
```

## Isolated Declarations DTS Emit
Expand All @@ -67,14 +90,17 @@ Oxc is at least 5x faster than `tsc` on small files, and 20x faster on larger fi
### MacBook Pro M3 Max

```
oxc - src/id.bench.js > UserSettings.tsx
37.16x faster than tsc
oxc - src/id.bench.js > parser.ts
20.15x faster than tsc
19.08x faster than tsc
oxc - src/id.bench.js > renderer.ts
19.85x faster than tsc
18.05x faster than tsc
oxc - src/id.bench.js > table.tsx
5.09x faster than tsc
4.40x faster than tsc
```

### Memory Usage
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/preset-typescript": "^7.24.7",
"@swc/core": "^1.7.28",
"oxc-transform": "^0.30.4",
"react-refresh": "^0.14.2",
"typescript": "^5.6.2",
"vitest": "^2.1.1"
},
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/transform.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ import { transformSync as swcTransform } from "@swc/core";
import { transformSync as babelTransform } from '@babel/core'
import { transform as oxcTransform } from "oxc-transform";

const development = true;
const refresh = true;

function oxc(filename, sourceText) {
return oxcTransform(filename, sourceText);
return oxcTransform(filename, sourceText, {
react: {
runtime: 'automatic',
development,
refresh
}
});
}

function swc(filename, sourceText) {
Expand All @@ -18,7 +27,9 @@ function swc(filename, sourceText) {
transform: {
treatConstEnumAsEnum: true,
react: {
runtime: 'automatic'
runtime: 'automatic',
development,
refresh,
}
},
preserveAllComments: false,
Expand All @@ -31,9 +42,11 @@ function babel(filename, sourceText) {
filename,
babelrc: false,
comments: false,
envName: 'development',
plugins: refresh ? [ "react-refresh/babel" ] : [],
presets: [
"@babel/preset-typescript",
["@babel/preset-react", { runtime: 'automatic' }],
["@babel/preset-react", { runtime: 'automatic', development }],
]
});
}
Expand Down

0 comments on commit 1d1517d

Please sign in to comment.