Skip to content

Commit 294e2dc

Browse files
committed
fix: report dts for cjs
1 parent 1d9289c commit 294e2dc

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/features/report.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface SizeInfo {
2828
brotliText: string
2929
}
3030

31-
export function ReportPlugin(cwd: string): Plugin {
31+
export function ReportPlugin(cwd: string, cjsDts?: boolean): Plugin {
3232
return {
3333
name: 'tsdown:report',
3434
async writeBundle(options, bundle) {
@@ -75,17 +75,16 @@ export function ReportPlugin(cwd: string): Plugin {
7575
return b.brotli - a.brotli
7676
})
7777

78+
const format = cjsDts ? 'cjs' : options.format
79+
const formatColor =
80+
format === 'es' ? blue : format === 'cjs' ? yellow : noop
81+
const formatText = formatColor(`[${prettyFormat(format)}]`)
82+
7883
for (const size of sizes) {
79-
const formatColor =
80-
options.format === 'es'
81-
? blue
82-
: options.format === 'cjs'
83-
? yellow
84-
: noop
8584
const filenameColor = size.dts ? green : noop
8685

8786
logger.info(
88-
formatColor(`[${prettyFormat(options.format)}]`),
87+
formatText,
8988
dim(`${outDir}/`) +
9089
filenameColor((size.isEntry ? bold : noop)(size.filename)),
9190
` `.repeat(filenameLength - size.filename.length),

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,12 @@ async function getBuildOptions(
206206
}),
207207
)
208208
}
209-
plugins.push(ShebangPlugin(cwd), report && ReportPlugin(cwd))
209+
plugins.push(ShebangPlugin(cwd))
210210
}
211+
if (report) {
212+
plugins.push(ReportPlugin(cwd, cjsDts))
213+
}
214+
211215
plugins.push(userPlugins)
212216

213217
const inputOptions = await mergeUserOptions(

0 commit comments

Comments
 (0)