@@ -1398,6 +1398,93 @@ test('should emit a declaration file per format (type: module)', async () => {
13981398 ] )
13991399} )
14001400
1401+ test ( 'should emit dts chunks per format' , async ( ) => {
1402+ const { outFiles } = await run (
1403+ getTestName ( ) ,
1404+ {
1405+ 'src/input1.ts' : `
1406+ import type { InternalType } from './shared.js'
1407+
1408+ export function getValue(value: InternalType) {
1409+ return value;
1410+ }
1411+ ` ,
1412+ 'src/input2.ts' : `
1413+ import type { InternalType } from './shared.js'
1414+
1415+ export function getValue(value: InternalType) {
1416+ return value;
1417+ }
1418+ ` ,
1419+ 'src/shared.ts' : `export type InternalType = 'foo'` ,
1420+ 'tsup.config.ts' : `
1421+ export default {
1422+ entry: ['./src/input1.ts', './src/input2.ts'],
1423+ format: ['esm', 'cjs'],
1424+ dts: true
1425+ }` ,
1426+ } ,
1427+ { entry : [ ] }
1428+ )
1429+ expect ( outFiles ) . toEqual ( [
1430+ 'input1.d.mts' ,
1431+ 'input1.d.ts' ,
1432+ 'input1.js' ,
1433+ 'input1.mjs' ,
1434+ 'input2.d.mts' ,
1435+ 'input2.d.ts' ,
1436+ 'input2.js' ,
1437+ 'input2.mjs' ,
1438+ 'shared-qBqaX8Tr.d.mts' ,
1439+ 'shared-qBqaX8Tr.d.ts' ,
1440+ ] )
1441+ } )
1442+
1443+ test ( 'should emit dts chunks per format (type: module)' , async ( ) => {
1444+ const { outFiles } = await run (
1445+ getTestName ( ) ,
1446+ {
1447+ 'src/input1.ts' : `
1448+ import type { InternalType } from './shared.js'
1449+
1450+ export function getValue(value: InternalType) {
1451+ return value;
1452+ }
1453+ ` ,
1454+ 'src/input2.ts' : `
1455+ import type { InternalType } from './shared.js'
1456+
1457+ export function getValue(value: InternalType) {
1458+ return value;
1459+ }
1460+ ` ,
1461+ 'src/shared.ts' : `export type InternalType = 'foo'` ,
1462+ 'tsup.config.ts' : `
1463+ export default {
1464+ entry: ['./src/input1.ts', './src/input2.ts'],
1465+ format: ['esm', 'cjs'],
1466+ dts: true
1467+ }` ,
1468+ 'package.json' : `{
1469+ "type": "module"
1470+ }` ,
1471+ } ,
1472+ { entry : [ ] }
1473+ )
1474+ expect ( outFiles ) . toEqual ( [
1475+ 'input1.cjs' ,
1476+ 'input1.d.cts' ,
1477+ 'input1.d.ts' ,
1478+ 'input1.js' ,
1479+ 'input2.cjs' ,
1480+ 'input2.d.cts' ,
1481+ 'input2.d.ts' ,
1482+ 'input2.js' ,
1483+ 'shared-qBqaX8Tr.d.cts' ,
1484+ 'shared-qBqaX8Tr.d.ts' ,
1485+ ] )
1486+ } )
1487+
14011488test ( 'should emit declaration files with experimentalDts' , async ( ) => {
14021489 const files = {
14031490 'package.json' : `
0 commit comments