@@ -1668,3 +1668,50 @@ test('should only include exported declarations with experimentalDts', async ()
1668
1668
expect ( entry2dts ) . toContain ( 'declare2' )
1669
1669
expect ( entry2dts ) . not . toContain ( 'declare1' )
1670
1670
} )
1671
+
1672
+ test ( '.d.ts files should be cleaned when --clean and --experimental-dts are provided' , async ( ) => {
1673
+ const filesFoo = {
1674
+ 'package.json' : `{ "name": "tsup-playground", "private": true }` ,
1675
+ 'foo.ts' : `export const foo = 1` ,
1676
+ }
1677
+
1678
+ const filesFooBar = {
1679
+ ...filesFoo ,
1680
+ 'bar.ts' : `export const bar = 2` ,
1681
+ }
1682
+
1683
+ // First run with both foo and bar
1684
+ const result1 = await run ( getTestName ( ) , filesFooBar , {
1685
+ entry : [ 'foo.ts' , 'bar.ts' ] ,
1686
+ flags : [ '--experimental-dts' ] ,
1687
+ } )
1688
+
1689
+ expect ( result1 . outFiles ) . toContain ( 'foo.d.ts' )
1690
+ expect ( result1 . outFiles ) . toContain ( 'foo.js' )
1691
+ expect ( result1 . outFiles ) . toContain ( 'bar.d.ts' )
1692
+ expect ( result1 . outFiles ) . toContain ( 'bar.js' )
1693
+
1694
+ // Second run with only foo
1695
+ const result2 = await run ( getTestName ( ) , filesFoo , {
1696
+ entry : [ 'foo.ts' ] ,
1697
+ flags : [ '--experimental-dts' ] ,
1698
+ } )
1699
+
1700
+ // When --clean is not provided, the previous bar.* files should still exist
1701
+ expect ( result2 . outFiles ) . toContain ( 'foo.d.ts' )
1702
+ expect ( result2 . outFiles ) . toContain ( 'foo.js' )
1703
+ expect ( result2 . outFiles ) . toContain ( 'bar.d.ts' )
1704
+ expect ( result2 . outFiles ) . toContain ( 'bar.js' )
1705
+
1706
+ // Third run with only foo and --clean
1707
+ const result3 = await run ( getTestName ( ) , filesFoo , {
1708
+ entry : [ 'foo.ts' ] ,
1709
+ flags : [ '--experimental-dts' , '--clean' ] ,
1710
+ } )
1711
+
1712
+ // When --clean is provided, the previous bar.* files should be deleted
1713
+ expect ( result3 . outFiles ) . toContain ( 'foo.d.ts' )
1714
+ expect ( result3 . outFiles ) . toContain ( 'foo.js' )
1715
+ expect ( result3 . outFiles ) . not . toContain ( 'bar.d.ts' )
1716
+ expect ( result3 . outFiles ) . not . toContain ( 'bar.js' )
1717
+ } )
1 commit comments
vercel[bot] commentedon Nov 21, 2023
Successfully deployed to the following URLs:
tsup – ./
tsup-git-main-egoist.vercel.app
tsup.vercel.app
tsup-egoist.vercel.app
tsup.egoist.dev