Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/plugin-dts/src/apiExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'node:fs';
import { join, relative } from 'node:path';
import type * as ApiExtractor from '@microsoft/api-extractor';
import { logger } from '@rsbuild/core';
Expand Down Expand Up @@ -53,7 +54,15 @@ export async function bundleDts(options: BundleOptions): Promise<void> {
relative(cwd, distPath),
`${entry.name}${dtsExtension}`,
);
const mainEntryPointFilePath = entry.path!.replace(/\?.*$/, '');

const mainEntryPointFilePath = entry.path;

if (!fs.existsSync(mainEntryPointFilePath)) {
throw new Error(
`Declaration entry file ${color.underline(entry.path)} not found.\nPlease ensure that your tsconfig file ${color.underline(tsconfigPath)} is correctly configured to generate declaration files. If needed, a custom tsconfig can be specified using the ${color.cyan('source.tsconfigPath')} option.`,
);
}

const internalConfig = {
mainEntryPointFilePath,
bundledPackages,
Expand Down Expand Up @@ -106,8 +115,9 @@ export async function bundleDts(options: BundleOptions): Promise<void> {
}),
);
} catch (e) {
const message = e instanceof Error ? e.message : e;
const error = new Error(
`${logPrefixApiExtractor} ${e} ${color.dim(`(${name})`)}`,
`${logPrefixApiExtractor} ${message} ${color.dim(`(${name})`)}`,
);
// do not log the stack trace, it is not helpful for users
error.stack = '';
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-dts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export type PluginDtsOptions = {
};

export type DtsEntry = {
name?: string;
path?: string;
name: string;
path: string;
};

export type DtsGenOptions = Omit<PluginDtsOptions, 'bundle'> & {
Expand Down
Loading