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"
66
7- const fixture = ( ...args : string [ ] ) => path . join ( __dirname , ' fixtures' , ...args )
7+ const fixture = ( ...args : string [ ] ) => path . join ( __dirname , " fixtures" , ...args )
88
9- test ( ' rollup' , async ( ) => {
9+ test ( " rollup" , async ( ) => {
1010 const bundle = await rollup ( {
11- input : fixture ( ' rollup/index.ts' ) ,
11+ input : fixture ( " rollup/index.ts" ) ,
1212 plugins : [
1313 swc . rollup ( {
1414 tsconfigFile : false ,
@@ -17,8 +17,8 @@ test('rollup', async () => {
1717 } )
1818
1919 const { output } = await bundle . generate ( {
20- format : ' cjs' ,
21- dir : fixture ( ' rollup/dist' ) ,
20+ format : " cjs" ,
21+ dir : fixture ( " rollup/dist" ) ,
2222 } )
2323
2424 assert . is (
@@ -34,24 +34,24 @@ exports.foo = foo;
3434 )
3535} )
3636
37- test ( ' read tsconfig' , async ( ) => {
37+ test ( " read tsconfig" , async ( ) => {
3838 const bundle = await rollup ( {
39- input : fixture ( ' read-tsconfig/index.tsx' ) ,
39+ input : fixture ( " read-tsconfig/index.tsx" ) ,
4040 plugins : [ swc . rollup ( ) ] ,
4141 } )
4242
4343 const { output } = await bundle . generate ( {
44- format : ' cjs' ,
45- dir : fixture ( ' read-tsconfig/dist' ) ,
44+ format : " cjs" ,
45+ dir : fixture ( " read-tsconfig/dist" ) ,
4646 } )
4747
4848 const code = output [ 0 ] . code
49- assert . match ( code , ' customJsxFactory' )
49+ assert . match ( code , " customJsxFactory" )
5050} )
5151
52- test ( ' custom swcrc' , async ( ) => {
52+ test ( " custom swcrc" , async ( ) => {
5353 const bundle = await rollup ( {
54- input : fixture ( ' custom-swcrc/index.tsx' ) ,
54+ input : fixture ( " custom-swcrc/index.tsx" ) ,
5555 plugins : [
5656 swc . rollup ( {
5757 tsconfigFile : false ,
@@ -60,17 +60,17 @@ test('custom swcrc', async () => {
6060 } )
6161
6262 const { output } = await bundle . generate ( {
63- format : ' cjs' ,
64- dir : fixture ( ' custom-swcrc/dist' ) ,
63+ format : " cjs" ,
64+ dir : fixture ( " custom-swcrc/dist" ) ,
6565 } )
6666
6767 const code = output [ 0 ] . code
68- assert . match ( code , ' customPragma' )
68+ assert . match ( code , " customPragma" )
6969} )
7070
71- test ( ' minify' , async ( ) => {
71+ test ( " minify" , async ( ) => {
7272 const bundle = await rollup ( {
73- input : fixture ( ' minify/index.ts' ) ,
73+ input : fixture ( " minify/index.ts" ) ,
7474 plugins : [
7575 swc . rollup ( {
7676 minify : true ,
@@ -79,14 +79,15 @@ test('minify', async () => {
7979 } )
8080
8181 const { output } = await bundle . generate ( {
82- format : ' cjs' ,
83- dir : fixture ( ' minify/dist' ) ,
82+ format : " cjs" ,
83+ dir : fixture ( " minify/dist" ) ,
8484 } )
8585
8686 const code = output [ 0 ] . code
87+ console . log ( code )
8788 assert . match (
8889 code ,
89- `var Foo1 =function Foo(){_classCallCheck(this,Foo);this.a=1}` ,
90+ `var Foo =function Foo(){_classCallCheck(this,Foo);this.a=1}` ,
9091 )
9192} )
9293
0 commit comments