Skip to content

Commit

Permalink
fix: use pre hook order to promise dts task (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 authored Jan 23, 2025
1 parent e3b145d commit fc6cf37
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/plugin-dts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,35 @@ export const pluginDts = (options: PluginDtsOptions = {}): RsbuildPlugin => ({
},
);

api.onAfterBuild(async ({ isFirstCompile }) => {
if (!isFirstCompile) {
return;
}

promisesResult = await Promise.all(dtsPromises);
});

api.onAfterBuild({
handler: ({ isFirstCompile }) => {
handler: async ({ isFirstCompile }) => {
if (!isFirstCompile) {
return;
}

for (const result of promisesResult) {
if (result.status === 'error') {
if (options.abortOnError) {
throw new Error(result.errorMessage);
}
result.errorMessage && logger.error(result.errorMessage);
logger.warn(
'With the `abortOnError` configuration currently turned off, type errors do not cause build failures, but they do not guarantee proper type file output.',
);
promisesResult = await Promise.all(dtsPromises);
},
// Set the order to 'pre' to ensure that when DTS files of multiple formats are generated simultaneously,
// all errors are thrown together before exiting the process.
order: 'pre',
});

api.onAfterBuild(({ isFirstCompile }) => {
if (!isFirstCompile) {
return;
}

for (const result of promisesResult) {
if (result.status === 'error') {
if (options.abortOnError) {
throw new Error(result.errorMessage);
}
result.errorMessage && logger.error(result.errorMessage);
logger.warn(
'With the `abortOnError` configuration currently turned off, type errors do not cause build failures, but they do not guarantee proper type file output.',
);
}
},
// Set the order to 'post' to ensure that when DTS files of multiple formats are generated
// simultaneously, all errors are thrown together before exiting the process.
order: 'post',
}
});

const killProcesses = () => {
Expand Down

0 comments on commit fc6cf37

Please sign in to comment.