@@ -11,6 +11,7 @@ import { getProductionDeps, loadPkg } from './load'
1111import { reportSize } from './lib/report-size'
1212import type { NormalizedOptions } from './'
1313import type { InputOptions , OutputOptions , Plugin } from 'rollup'
14+ import { FixDtsDefaultCjsExportsPlugin } from 'fix-dts-default-cjs-exports/rollup'
1415
1516const logger = createLogger ( )
1617
@@ -89,25 +90,6 @@ const getRollupConfig = async (
8990 } ,
9091 }
9192
92- const fixCjsExport : Plugin = {
93- name : 'tsup:fix-cjs-export' ,
94- renderChunk ( code , info ) {
95- if (
96- info . type !== 'chunk' ||
97- ! / \. ( t s | c t s ) $ / . test ( info . fileName ) ||
98- ! info . isEntry ||
99- info . exports ?. length !== 1 ||
100- info . exports [ 0 ] !== 'default'
101- )
102- return
103-
104- return code . replace (
105- / (?< = (?< = [ ; } ] | ^ ) \s * e x p o r t \s * ) { \s * ( [ \w $ ] + ) \s * a s \s + d e f a u l t \s * } / ,
106- `= $1` ,
107- )
108- } ,
109- }
110-
11193 return {
11294 inputConfig : {
11395 input : dtsOptions . entry ,
@@ -167,7 +149,7 @@ const getRollupConfig = async (
167149 entryFileNames : `[name]${ outputExtension } ` ,
168150 chunkFileNames : `[name]-[hash]${ outputExtension } ` ,
169151 plugins : [
170- format === 'cjs' && options . cjsInterop && fixCjsExport ,
152+ format === 'cjs' && options . cjsInterop && FixDtsDefaultCjsExportsPlugin ( ) ,
171153 ] . filter ( Boolean ) ,
172154 }
173155 } ) ,
0 commit comments