-
Notifications
You must be signed in to change notification settings - Fork 7
/
wasm.test.ts
47 lines (44 loc) · 1 KB
/
wasm.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { type Options, transform } from '@swc/core'
import * as path from 'node:path'
import * as url from 'node:url'
import { expect, test } from 'vitest'
const options: Options = {
jsc: {
parser: {
syntax: 'ecmascript',
jsx: true,
},
experimental: {
plugins: [[
path.join(
path.dirname(url.fileURLToPath(import.meta.url)),
'swc_plugin_vue_jsx.wasm'
),
{},
]],
},
},
}
test('transform basic JSX', async () => {
const code = `<div></div>`
const output = await transform(code, options)
expect(output.code).toMatchInlineSnapshot(`
"import { createVNode as _createVNode } from "vue";
_createVNode("div", null, null);
"
`)
})
test('issue #4', async () => {
const code = `
let a = {};
a.b = 1;
let b = a?.b;
`
const output = await transform(code, options)
expect(output.code).toMatchInlineSnapshot(`
"var a = {};
a.b = 1;
var b = a === null || a === void 0 ? void 0 : a.b;
"
`)
})