Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target es2015 #12

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 48 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,54 @@ React development + refresh is 6x faster than swc and 20x - 70x faster than Babe
### GitHub Actions `ubuntu-latest`

```
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: false, reactDev: false)
5.38x faster than swc
57.51x faster than babel

oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: true, reactDev: false)
5.15x faster than swc
47.33x faster than babel

oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: false, reactDev: true)
5.08x faster than swc
54.38x faster than babel

oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: true, reactDev: true)
4.99x faster than swc
48.33x faster than babel

oxc - src/transform.bench.ts > parser.ts (sourceMap: false, reactDev: false)
3.57x faster than swc
39.97x faster than babel

oxc - src/transform.bench.ts > parser.ts (sourceMap: true, reactDev: false)
3.45x faster than swc
31.61x faster than babel

oxc - src/transform.bench.ts > renderer.ts (sourceMap: false, reactDev: false)
3.64x faster than swc
27.85x faster than babel

oxc - src/transform.bench.ts > renderer.ts (sourceMap: true, reactDev: false)
3.56x faster than swc
19.13x faster than babel

oxc - src/transform.bench.ts > table.tsx (sourceMap: false, reactDev: false)
4.13x faster than swc
34.22x faster than babel

oxc - src/transform.bench.ts > table.tsx (sourceMap: true, reactDev: false)
3.90x faster than swc
26.15x faster than babel

oxc - src/transform.bench.ts > table.tsx (sourceMap: false, reactDev: true)
4.30x faster than swc
44.17x faster than babel

oxc - src/transform.bench.ts > table.tsx (sourceMap: true, reactDev: true)
3.93x faster than swc
32.84x faster than babel
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: false, reactDev: false, target: esnext)
4.18x faster than swc
49.04x faster than babel
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: false, reactDev: false, target: es2015)
5.71x faster than swc
46.49x faster than babel
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: true, reactDev: false, target: esnext)
4.23x faster than swc
40.18x faster than babel
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: false, reactDev: true, target: esnext)
5.41x faster than swc
64.39x faster than babel
oxc - src/transform.bench.ts > UserSettings.tsx (sourceMap: true, reactDev: true, target: esnext)
5.17x faster than swc
53.43x faster than babel
oxc - src/transform.bench.ts > parser.ts (sourceMap: false, reactDev: false, target: esnext)
3.13x faster than swc
34.59x faster than babel
oxc - src/transform.bench.ts > parser.ts (sourceMap: false, reactDev: false, target: es2015)
3.51x faster than swc
31.86x faster than babel
oxc - src/transform.bench.ts > parser.ts (sourceMap: true, reactDev: false, target: esnext)
3.03x faster than swc
26.98x faster than babel
oxc - src/transform.bench.ts > renderer.ts (sourceMap: false, reactDev: false, target: esnext)
3.21x faster than swc
23.76x faster than babel
oxc - src/transform.bench.ts > renderer.ts (sourceMap: false, reactDev: false, target: es2015)
3.62x faster than swc
22.93x faster than babel
oxc - src/transform.bench.ts > renderer.ts (sourceMap: true, reactDev: false, target: esnext)
3.11x faster than swc
18.77x faster than babel
oxc - src/transform.bench.ts > table.tsx (sourceMap: false, reactDev: false, target: esnext)
3.74x faster than swc
30.57x faster than babel
oxc - src/transform.bench.ts > table.tsx (sourceMap: false, reactDev: false, target: es2015)
4.32x faster than swc
30.96x faster than babel
oxc - src/transform.bench.ts > table.tsx (sourceMap: true, reactDev: false, target: esnext)
3.59x faster than swc
26.30x faster than babel
oxc - src/transform.bench.ts > table.tsx (sourceMap: false, reactDev: true, target: esnext)
4.71x faster than swc
46.03x faster than babel
oxc - src/transform.bench.ts > table.tsx (sourceMap: true, reactDev: true, target: esnext)
4.45x faster than swc
37.05x faster than babel
```

## Isolated Declarations DTS Emit
Expand Down
28 changes: 16 additions & 12 deletions src/transform.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ type RunOptions = {
sourceText: string;
sourceMap: boolean;
reactDev: boolean;
target: 'esnext' | 'es2015'
};

function oxc(options: RunOptions) {
return oxcTransform(options.filename, options.sourceText, {
sourcemap: options.sourceMap,
target: options.target,
react: {
runtime: "automatic",
development: options.reactDev,
Expand All @@ -29,7 +31,7 @@ function swc(options: RunOptions) {
sourceMaps: options.sourceMap,
swcrc: false,
jsc: {
target: "esnext",
target: options.target,
transform: {
treatConstEnumAsEnum: true,
react: {
Expand Down Expand Up @@ -67,30 +69,32 @@ function babel(options: RunOptions) {
}

type Case = [
filename: string,
sourceMap: boolean,
reactDev: boolean,
sourceText: string,
filename: RunOptions['filename'],
sourceMap: RunOptions['sourceMap'],
reactDev: RunOptions['reactDev'],
target: RunOptions['target'],
sourceText: RunOptions['sourceText'],
];
const cases = fs.readdirSync("./fixtures").flatMap((filename): Case[] => {
const sourceText = fs.readFileSync(`./fixtures/${filename}`, "utf8");
const base: Case[] = [
[filename, false, false, sourceText],
[filename, true, false, sourceText],
[filename, false, false, "esnext", sourceText],
[filename, false, false, "es2015", sourceText],
[filename, true, false, "esnext", sourceText],
];
if (!filename.endsWith(".tsx")) return base;
return [
...base,
[filename, false, true, sourceText],
[filename, true, true, sourceText],
[filename, false, true, "esnext", sourceText],
[filename, true, true, "esnext", sourceText],
];
});

describe.each(cases)(
"%s (sourceMap: %s, reactDev: %s)",
(filename, sourceMap, reactDev, sourceText) => {
"%s (sourceMap: %s, reactDev: %s, target: %s)",
(filename, sourceMap, reactDev, target, sourceText) => {
for (const fn of [oxc, swc, babel]) {
const options: RunOptions = { filename, sourceText, sourceMap, reactDev };
const options: RunOptions = { filename, sourceText, sourceMap, reactDev, target };
const code = fn(options).code;
// fs.writeFileSync(`./output/${filename}.${fn.name}.js`, code);
assert(code);
Expand Down