Skip to content

Commit 2e24b00

Browse files
committed
fix(tsc): add warning for failed emission
1 parent e8520e7 commit 2e24b00

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/tsc/emit-compiler.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function createTsProgram({
6565
baseDir,
6666
)
6767

68-
debug(`Creating program for root project: ${baseDir}`)
68+
debug(`creating program for root project: ${baseDir}`)
6969
return createTsProgramFromParsedConfig({
7070
parsedConfig,
7171
fsSystem,
@@ -181,9 +181,17 @@ export function tscEmitCompiler(tscOptions: TscOptions): TscResult {
181181
// redirected output from a composite project build), the emit callback above
182182
// will never be invoked. In that case, fall back to the text of the source
183183
// file itself so that callers still receive a declaration string.
184-
if (!dtsCode && file.isDeclarationFile) {
185-
debug('nothing was emitted. fallback to sourceFile text.')
186-
dtsCode = file.getFullText()
184+
if (!dtsCode) {
185+
debug('nothing was emitted.')
186+
187+
if (file.isDeclarationFile) {
188+
debug('source file is a declaration file.')
189+
dtsCode = file.getFullText()
190+
} else {
191+
console.warn(
192+
'[rolldown-plugin-dts] Warning: Failed to emit declaration file. Please try to enable `eager` option (`dts.eager` for tsdown).',
193+
)
194+
}
187195
}
188196

189197
return { code: dtsCode, map }

0 commit comments

Comments
 (0)