Skip to content

Commit e95fc34

Browse files
committed
refactor: use compiler-rs instead of compiler and babel
1 parent 73be347 commit e95fc34

File tree

373 files changed

+23005
-11985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

373 files changed

+23005
-11985
lines changed

.github/workflows/release.yml

Lines changed: 410 additions & 34 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ coverage
2222
# nyc test coverage
2323
.nyc_output
2424

25-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26-
.grunt
25+
# Snowpack dependency directory (https://snowpack.dev/)
26+
web_modules/
2727

2828
# Bower dependency directory (https://bower.io/)
2929
bower_components
@@ -58,6 +58,10 @@ typings/
5858

5959
# dotenv environment variables file
6060
.env
61+
.env.development.local
62+
.env.test.local
63+
.env.production.local
64+
.env.local
6165

6266
# parcel-bundler cache (https://parceljs.org/)
6367
.cache
@@ -82,3 +86,120 @@ dist
8286

8387
# vitepress
8488
cache
89+
90+
### Created by https://www.gitignore.io
91+
### Rust ###
92+
# Generated by Cargo
93+
# will have compiled files and executables
94+
debug/
95+
target/
96+
97+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
98+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
99+
Cargo.lock
100+
101+
# These are backup files generated by rustfmt
102+
**/*.rs.bk
103+
104+
# MSVC Windows builds of rustc generate these, which store debugging information
105+
*.pdb
106+
107+
# Diagnostic reports (https://nodejs.org/api/report.html)
108+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
109+
110+
# TypeScript cache
111+
*.tsbuildinfo
112+
113+
# Microbundle cache
114+
.rpt2_cache/
115+
.rts2_cache_cjs/
116+
.rts2_cache_es/
117+
.rts2_cache_umd/
118+
119+
# parcel-bundler cache (https://parceljs.org/)
120+
.cache
121+
.parcel-cache
122+
123+
# Next.js build output
124+
.next
125+
out
126+
127+
# Nuxt.js build / generate output
128+
.nuxt
129+
dist
130+
131+
# Gatsby files
132+
.cache/
133+
134+
# Docusaurus cache and generated files
135+
.docusaurus
136+
137+
# Serverless directories
138+
.serverless/
139+
140+
# FuseBox cache
141+
.fusebox/
142+
143+
# DynamoDB Local files
144+
.dynamodb/
145+
146+
# TernJS port file
147+
.tern-port
148+
149+
# Stores VSCode versions used for testing VSCode extensions
150+
.vscode-test
151+
152+
# yarn v2
153+
.yarn/cache
154+
.yarn/unplugged
155+
.yarn/build-state.yml
156+
.yarn/install-state.gz
157+
.pnp.*
158+
159+
*.node
160+
*.wasm
161+
162+
### Node Patch ###
163+
# Serverless Webpack directories
164+
.webpack/
165+
166+
# Optional stylelint cache
167+
.stylelintcache
168+
169+
# SvelteKit build / generate output
170+
.svelte-kit
171+
172+
### Created by https://www.gitignore.io
173+
### macOS ###
174+
# General
175+
.DS_Store
176+
.AppleDouble
177+
.LSOverride
178+
179+
# Icon must end with two \r
180+
Icon
181+
182+
# Thumbnails
183+
._*
184+
185+
# Files that might appear in the root of a volume
186+
.DocumentRevisions-V100
187+
.fseventsd
188+
.Spotlight-V100
189+
.TemporaryItems
190+
.Trashes
191+
.VolumeIcon.icns
192+
.com.apple.timemachine.donotpresent
193+
194+
# Directories potentially created on remote AFP share
195+
.AppleDB
196+
.AppleDesktop
197+
Network Trash Folder
198+
Temporary Items
199+
.apdisk
200+
201+
### macOS Patch ###
202+
# iCloud generated files
203+
*.icloud
204+
205+
flamegraph.svg

benchmark/bench.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* eslint-disable */
2+
import { transformSync } from '@babel/core'
3+
import vueJsxVapor from '@vue-jsx-vapor/babel'
4+
import { transform as rsTransform } from '@vue-jsx-vapor/compiler-rs'
5+
import vueJsx from '@vue/babel-plugin-jsx'
6+
import { Bench } from 'tinybench'
7+
function vueJsxTransform(source) {
8+
transformSync(source, {
9+
plugins: [vueJsx],
10+
filename: 'index.jsx',
11+
sourceMaps: false,
12+
sourceFileName: 'index.jsx',
13+
babelrc: false,
14+
configFile: false,
15+
})
16+
}
17+
18+
function vueJsxVaporTransform(source) {
19+
transformSync(source, {
20+
plugins: [vueJsxVapor],
21+
filename: 'index.jsx',
22+
sourceMaps: false,
23+
sourceFileName: 'index.jsx',
24+
babelrc: false,
25+
configFile: false,
26+
})
27+
}
28+
29+
const bench = new Bench()
30+
31+
const source = `export default () => <>${`
32+
<Comp
33+
foo={foo}
34+
ref={foo}
35+
onClick={()=> alert(1)}
36+
v-show={true}
37+
v-model={foo}
38+
v-once
39+
v-slot={foo}
40+
>
41+
<div
42+
v-if={foo}
43+
v-for={({item}, index) in list}
44+
key={key}
45+
>
46+
{item}
47+
</div>
48+
<span v-else-if={bar}>
49+
bar
50+
</span>
51+
<Foo v-else>
52+
default
53+
<template v-slot:bar={{ bar }}>
54+
{bar}
55+
</template>
56+
</Foo>
57+
</Comp>`.repeat(12)}
58+
</>`
59+
60+
console.time('vue-jsx + babel-parser ')
61+
vueJsxTransform(source)
62+
console.timeEnd('vue-jsx + babel-parser ')
63+
64+
console.time('@vue-jsx-vapor/compiler + babel-parser ')
65+
vueJsxVaporTransform(source)
66+
console.timeEnd('@vue-jsx-vapor/compiler + babel-parser ')
67+
68+
console.time('@vue-jsx-vapor/compiler-rs + oxc-parser ')
69+
rsTransform(source)
70+
console.timeEnd('@vue-jsx-vapor/compiler-rs + oxc-parser ')
71+
72+
bench.add('vue-jsx + babel-parser', () => {
73+
vueJsxTransform(source)
74+
})
75+
76+
bench.add('compiler-js + babel-parser', () => {
77+
vueJsxVaporTransform(source)
78+
})
79+
80+
bench.add('compiler-rs + oxc-parser', () => {
81+
rsTransform(source)
82+
})
83+
84+
await bench.run()
85+
86+
console.table(bench.table())

benchmark/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "module",
3+
"scripts": {
4+
"bench": "node ./bench.js"
5+
},
6+
"devDependencies": {
7+
"@babel/core": "catalog:",
8+
"@vue-jsx-vapor/babel": "2.6.8",
9+
"@vue-jsx-vapor/compiler-rs": "workspace:*",
10+
"@vue/babel-plugin-jsx": "^1.5.0",
11+
"tinybench": "^5.0.1"
12+
}
13+
}

eslint.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default [
99
'unicorn/no-new-array',
1010
'unicorn/prefer-dom-node-remove',
1111
'unused-imports/no-unused-imports',
12+
'@eslint-community/eslint-comments/no-unlimited-disable',
1213
)
1314
.append([
1415
{

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
"scripts": {
2828
"dev": "pnpm run --filter=\"./packages/*\" --parallel dev",
2929
"build": "pnpm run --filter=\"./packages/*\" --parallel build",
30+
"bench": "pnpm run -C ./benchmark bench",
3031
"typecheck": "tsmc --noEmit",
3132
"lint": "eslint .",
3233
"play": "npm -C playground run dev",
3334
"test": "vitest",
35+
"test-rs": "pnpm run --filter=\"compiler-rs\" test",
3436
"release": "bumpp -r --all -x 'pnpm run changelog'",
3537
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
3638
"docs:dev": "pnpm run -C ./docs dev",
@@ -44,7 +46,7 @@
4446
"bumpp": "^10.2.3",
4547
"conventional-changelog-cli": "^5.0.0",
4648
"eslint": "^9.36.0",
47-
"tsdown": "^0.12.9",
49+
"tsdown": "^0.15.12",
4850
"typescript": "^5.9.2",
4951
"unplugin-raw": "^0.5.1",
5052
"vite": "catalog:",

packages/babel/package.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)