Skip to content

Commit 112099a

Browse files
authored
test: use @rollup/plugin-swc with rolldown-vite for ecma decorators (#682)
1 parent 153bb2a commit 112099a

File tree

3 files changed

+205
-7
lines changed

3 files changed

+205
-7
lines changed

playground/vue-jsx-ts-built-in/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
},
1515
"devDependencies": {
1616
"@babel/plugin-syntax-decorators": "^7.27.1",
17+
"@rollup/plugin-swc": "^0.4.0",
18+
"@swc/core": "^1.13.5",
1719
"@vitejs/plugin-vue": "workspace:*",
1820
"@vitejs/plugin-vue-jsx": "workspace:*"
1921
}

playground/vue-jsx-ts-built-in/vite.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from 'vite'
2+
import * as vite from 'vite'
23
import vueJsxPlugin from '@vitejs/plugin-vue-jsx'
34
import vuePlugin from '@vitejs/plugin-vue'
45
import babelPluginSyntaxDecorators from '@babel/plugin-syntax-decorators'
6+
import swc from '@rollup/plugin-swc'
57

68
export default defineConfig({
79
plugins: [
@@ -17,6 +19,25 @@ export default defineConfig({
1719
],
1820
}),
1921
vuePlugin(),
22+
// rolldown-vite does not support ecma decorators yet, use SWC to lower them
23+
// https://github.com/oxc-project/oxc/issues/9170
24+
'rolldownVersion' in vite &&
25+
vite.withFilter(
26+
{
27+
...swc({
28+
swc: {
29+
jsc: {
30+
parser: { decorators: true, decoratorsBeforeExport: true },
31+
// NOTE: SWC doesn't support '2023-11' version yet
32+
transform: { decoratorVersion: '2022-03' },
33+
},
34+
},
35+
}),
36+
},
37+
{
38+
transform: { id: /\/decorators\//, code: '@' },
39+
},
40+
),
2041
],
2142
build: {
2243
// to make tests faster

pnpm-lock.yaml

Lines changed: 182 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)