Skip to content

feat: transpile typescript code instead of transform #60

New issue

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

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

Already on GitHub? # to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ Install package:

```sh
# npm
npm install vue-sfc-transformer vue @vue/compiler-core esbuild
npm install vue-sfc-transformer vue @vue/compiler-core

# pnpm
pnpm install vue-sfc-transformer vue @vue/compiler-core esbuild
pnpm install vue-sfc-transformer vue @vue/compiler-core
```

```js
import { parse as parseSFC } from '@vue/compiler-sfc'
import { transform } from 'esbuild'

import { preTranspileScriptSetup, transpileVueTemplate } from 'vue-sfc-transformer'

const src = `
Expand All @@ -47,10 +45,6 @@ const templateBlockContents = await transpileVueTemplate(
sfc.descriptor.template.content,
sfc.descriptor.template.ast,
sfc.descriptor.template.loc.start.offset,
async (code) => {
const res = await transform(code, { loader: 'ts', target: 'esnext' })
return res.code
},
)
console.log(templateBlockContents)
// <div v-if="test" />
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dist"
],
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
},
"scripts": {
"build": "unbuild",
Expand All @@ -45,11 +45,12 @@
},
"peerDependencies": {
"@vue/compiler-core": "^3.5.13",
"esbuild": "*",
"typescript": "5.8.3",
"vue": "^3.5.13"
},
"dependencies": {
"@babel/parser": "^7.27.0"
"@babel/parser": "^7.27.0",
"@teages/oxc-blank-space": "^0.1.1"
},
"devDependencies": {
"@antfu/eslint-config": "4.13.2",
Expand All @@ -60,7 +61,6 @@
"@vue/compiler-dom": "3.5.16",
"bumpp": "10.1.1",
"changelogithub": "13.15.0",
"esbuild": "0.25.5",
"eslint": "9.28.0",
"exsolve": "1.0.5",
"installed-check": "9.3.0",
Expand Down
Loading