File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { isCallOf } from 'ast-kit'
2
+ import { expect , test } from 'vitest'
3
+ import { transform } from '../src/core/transform'
4
+ import { RemoveNode } from '../src/transformers'
5
+ import type { OptionsResolved } from '../src/core/options'
6
+
7
+ test ( 'remove node' , async ( ) => {
8
+ const source = `const comp = defineComponent({
9
+ render() {
10
+ return []
11
+ }
12
+ })
13
+ console.log(mutable({} as const))
14
+ `
15
+
16
+ const options : Pick < OptionsResolved , 'parserOptions' | 'transformer' > = {
17
+ transformer : [
18
+ RemoveNode (
19
+ ( node ) => node . type === 'ReturnStatement' || isCallOf ( node , 'mutable' ) ,
20
+ ) ,
21
+ ] ,
22
+ parserOptions : { } ,
23
+ }
24
+ const code = ( await transform ( source , 'foo.ts' , options ) ) ?. code
25
+ expect ( code ) . toMatchInlineSnapshot ( `
26
+ "const comp = defineComponent({
27
+ render() {
28
+
29
+ }
30
+ })
31
+ console.log()
32
+ "
33
+ ` )
34
+ } )
You can’t perform that action at this time.
0 commit comments