diff --git a/e2e/cases/dts/index.test.ts b/e2e/cases/dts/index.test.ts index a6bd87f2..31b392cd 100644 --- a/e2e/cases/dts/index.test.ts +++ b/e2e/cases/dts/index.test.ts @@ -16,7 +16,6 @@ test('dts when bundle: true', async () => { const fixturePath = join(__dirname, 'bundle'); const { entryFiles } = await buildAndGetResults(fixturePath, 'dts'); - console.log('entryFiles: ', entryFiles); expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true); expect(entryFiles.cjs!.endsWith('index.d.ts')).toEqual(true); }); diff --git a/packages/plugin-dts/src/index.ts b/packages/plugin-dts/src/index.ts index 8f1dc059..1b13ab17 100644 --- a/packages/plugin-dts/src/index.ts +++ b/packages/plugin-dts/src/index.ts @@ -25,7 +25,6 @@ export const pluginDts = ( setup(api) { const { tsconfigPath, distPath, bundle, isWatch } = options; - let isFirstCompile = true; api.onBeforeBuild(async ({ environments }) => { const cwd = process.cwd(); @@ -48,7 +47,7 @@ export const pluginDts = ( const declarationDir = getDeclarationDir(bundle, distPath) || './dist'; let entry = ''; - if (options.bundle === true) { + if (bundle === true) { const entrySourcePath = join( cwd, environments.esm?.config.source.entry?.main as string, @@ -62,7 +61,7 @@ export const pluginDts = ( } const onComplete = (isSuccess: boolean) => { - if (isSuccess && options.bundle === true) { + if (isSuccess && bundle === true) { bundleDts({ cwd, outDir, @@ -79,12 +78,11 @@ export const pluginDts = ( rootDir, declarationDir, }, - isFirstCompile, onComplete, isWatch, ); - if (options.bundle === true && !isWatch) { + if (bundle === true && !isWatch) { bundleDts({ cwd, outDir, @@ -92,10 +90,6 @@ export const pluginDts = ( tsconfigPath, }); } - - if (isFirstCompile) { - isFirstCompile = false; - } }); }, }); diff --git a/packages/plugin-dts/src/tsc.ts b/packages/plugin-dts/src/tsc.ts index 29622926..88060fc2 100644 --- a/packages/plugin-dts/src/tsc.ts +++ b/packages/plugin-dts/src/tsc.ts @@ -11,7 +11,6 @@ export type emitDtsOptions = { export function emitDts( options: emitDtsOptions, - isFirstCompile: boolean, onComplete: (isSuccess: boolean) => void, isWatch = false, ) { @@ -73,7 +72,7 @@ export function emitDts( } logger.info('TypeScript compilation succeeded\n'); - } else if (isFirstCompile) { + } else { const createProgram = ts.createSemanticDiagnosticsBuilderProgram; const formatHost: ts.FormatDiagnosticsHost = { getCanonicalFileName: (path) => path,