diff --git a/e2e/cases/dts/index.test.ts b/e2e/cases/dts/index.test.ts index 4aa50d7cc..08e0a903d 100644 --- a/e2e/cases/dts/index.test.ts +++ b/e2e/cases/dts/index.test.ts @@ -90,7 +90,7 @@ describe('dts when bundle: true', () => { 'dts', ); - expect(entryFiles.esm).toEqual('./dist/esm/index.d.ts'); + expect(entryFiles.esm).toEqual('./dist/esm/main.d.ts'); expect(entries).toMatchSnapshot(); }); @@ -113,7 +113,7 @@ describe('dts when bundle: true', () => { 'dts', ); - expect(entryFiles.esm).toEqual('./dist/custom/index.d.ts'); + expect(entryFiles.esm).toEqual('./dist/custom/main.d.ts'); }); test('abortOnError: false', async () => { @@ -135,7 +135,7 @@ describe('dts when bundle: true', () => { 'dts', ); - expect(entryFiles.cjs).toEqual('./dist/cjs/index.d.cts'); + expect(entryFiles.cjs).toEqual('./dist/cjs/main.d.cts'); }); test('bundleName -- set source.entry', async () => { diff --git a/packages/plugin-dts/src/apiExtractor.ts b/packages/plugin-dts/src/apiExtractor.ts index 0426f6750..60ee74bdd 100644 --- a/packages/plugin-dts/src/apiExtractor.ts +++ b/packages/plugin-dts/src/apiExtractor.ts @@ -14,7 +14,7 @@ export type BundleOptions = { cwd: string; outDir: string; dtsExtension: string; - dtsEntry: DtsEntry; + dtsEntry: Required; tsconfigPath?: string; }; @@ -24,7 +24,10 @@ export async function bundleDts(options: BundleOptions): Promise { cwd, outDir, dtsExtension, - dtsEntry, + dtsEntry = { + name: 'index', + path: 'index.d.ts', + }, tsconfigPath = 'tsconfig.json', } = options; try { @@ -32,9 +35,9 @@ export async function bundleDts(options: BundleOptions): Promise { const untrimmedFilePath = join( cwd, relative(cwd, outDir), - `${dtsEntry.name ?? 'index'}${dtsExtension}`, + `${dtsEntry.name}${dtsExtension}`, ); - const mainEntryPointFilePath = dtsEntry.path ?? 'index.d.ts'; + const mainEntryPointFilePath = dtsEntry.path; const internalConfig = { mainEntryPointFilePath, // TODO: use !externals