1
- import { test } from ' uvu'
2
- import assert from ' uvu/assert'
3
- import path from ' path'
4
- import swc from ' ../dist'
5
- import { rollup } from ' rollup'
1
+ import { test } from " uvu"
2
+ import assert from " uvu/assert"
3
+ import path from " path"
4
+ import swc from " ../dist"
5
+ import { rollup } from " rollup"
6
6
7
- const fixture = ( ...args : string [ ] ) => path . join ( __dirname , ' fixtures' , ...args )
7
+ const fixture = ( ...args : string [ ] ) => path . join ( __dirname , " fixtures" , ...args )
8
8
9
- test ( ' rollup' , async ( ) => {
9
+ test ( " rollup" , async ( ) => {
10
10
const bundle = await rollup ( {
11
- input : fixture ( ' rollup/index.ts' ) ,
11
+ input : fixture ( " rollup/index.ts" ) ,
12
12
plugins : [
13
13
swc . rollup ( {
14
14
tsconfigFile : false ,
@@ -17,8 +17,8 @@ test('rollup', async () => {
17
17
} )
18
18
19
19
const { output } = await bundle . generate ( {
20
- format : ' cjs' ,
21
- dir : fixture ( ' rollup/dist' ) ,
20
+ format : " cjs" ,
21
+ dir : fixture ( " rollup/dist" ) ,
22
22
} )
23
23
24
24
assert . is (
@@ -34,24 +34,24 @@ exports.foo = foo;
34
34
)
35
35
} )
36
36
37
- test ( ' read tsconfig' , async ( ) => {
37
+ test ( " read tsconfig" , async ( ) => {
38
38
const bundle = await rollup ( {
39
- input : fixture ( ' read-tsconfig/index.tsx' ) ,
39
+ input : fixture ( " read-tsconfig/index.tsx" ) ,
40
40
plugins : [ swc . rollup ( ) ] ,
41
41
} )
42
42
43
43
const { output } = await bundle . generate ( {
44
- format : ' cjs' ,
45
- dir : fixture ( ' read-tsconfig/dist' ) ,
44
+ format : " cjs" ,
45
+ dir : fixture ( " read-tsconfig/dist" ) ,
46
46
} )
47
47
48
48
const code = output [ 0 ] . code
49
- assert . match ( code , ' customJsxFactory' )
49
+ assert . match ( code , " customJsxFactory" )
50
50
} )
51
51
52
- test ( ' custom swcrc' , async ( ) => {
52
+ test ( " custom swcrc" , async ( ) => {
53
53
const bundle = await rollup ( {
54
- input : fixture ( ' custom-swcrc/index.tsx' ) ,
54
+ input : fixture ( " custom-swcrc/index.tsx" ) ,
55
55
plugins : [
56
56
swc . rollup ( {
57
57
tsconfigFile : false ,
@@ -60,17 +60,17 @@ test('custom swcrc', async () => {
60
60
} )
61
61
62
62
const { output } = await bundle . generate ( {
63
- format : ' cjs' ,
64
- dir : fixture ( ' custom-swcrc/dist' ) ,
63
+ format : " cjs" ,
64
+ dir : fixture ( " custom-swcrc/dist" ) ,
65
65
} )
66
66
67
67
const code = output [ 0 ] . code
68
- assert . match ( code , ' customPragma' )
68
+ assert . match ( code , " customPragma" )
69
69
} )
70
70
71
- test ( ' minify' , async ( ) => {
71
+ test ( " minify" , async ( ) => {
72
72
const bundle = await rollup ( {
73
- input : fixture ( ' minify/index.ts' ) ,
73
+ input : fixture ( " minify/index.ts" ) ,
74
74
plugins : [
75
75
swc . rollup ( {
76
76
minify : true ,
@@ -79,14 +79,15 @@ test('minify', async () => {
79
79
} )
80
80
81
81
const { output } = await bundle . generate ( {
82
- format : ' cjs' ,
83
- dir : fixture ( ' minify/dist' ) ,
82
+ format : " cjs" ,
83
+ dir : fixture ( " minify/dist" ) ,
84
84
} )
85
85
86
86
const code = output [ 0 ] . code
87
+ console . log ( code )
87
88
assert . match (
88
89
code ,
89
- `var Foo1 =function Foo(){_classCallCheck(this,Foo);this.a=1}` ,
90
+ `var Foo =function Foo(){_classCallCheck(this,Foo);this.a=1}` ,
90
91
)
91
92
} )
92
93
0 commit comments