这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: fixed experimental dts error #1198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 3 additions & 3 deletions src/api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ async function rollupDtsFiles(
}
}

function cleanDtsFiles(options: NormalizedOptions) {
async function cleanDtsFiles(options: NormalizedOptions) {
if (options.clean) {
removeFiles(['**/*.d.{ts,mts,cts}'], options.outDir)
await removeFiles(['**/*.d.{ts,mts,cts}'], options.outDir)
}
}

Expand All @@ -156,7 +156,7 @@ export async function runDtsRollup(
if (!exports) {
throw new Error('Unexpected internal error: dts exports is not define')
}
cleanDtsFiles(options)
await cleanDtsFiles(options)
for (const format of options.format) {
await rollupDtsFiles(options, exports, format)
}
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,21 @@ export async function build(_options: Options) {
logger.info('CLI', 'Running in watch mode')
}

const experimentalDtsTask = async () => {
if (!options.dts && options.experimentalDts) {
const exports = runTypeScriptCompiler(options);
await runDtsRollup(options, exports);
}
}

const dtsTask = async () => {
if (options.dts && options.experimentalDts) {
throw new Error(
"You can't use both `dts` and `experimentalDts` at the same time",
)
}

experimentalDtsTask();

if (options.experimentalDts) {
const exports = runTypeScriptCompiler(options)
Expand Down Expand Up @@ -351,6 +360,8 @@ export async function build(_options: Options) {
}),
])

experimentalDtsTask()

if (options.onSuccess) {
if (typeof options.onSuccess === 'function') {
onSuccessCleanup = await options.onSuccess()
Expand Down