Skip to content

Commit fc6cf37

Browse files
authored
fix: use pre hook order to promise dts task (#702)
1 parent e3b145d commit fc6cf37

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

packages/plugin-dts/src/index.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,35 +135,35 @@ export const pluginDts = (options: PluginDtsOptions = {}): RsbuildPlugin => ({
135135
},
136136
);
137137

138-
api.onAfterBuild(async ({ isFirstCompile }) => {
139-
if (!isFirstCompile) {
140-
return;
141-
}
142-
143-
promisesResult = await Promise.all(dtsPromises);
144-
});
145-
146138
api.onAfterBuild({
147-
handler: ({ isFirstCompile }) => {
139+
handler: async ({ isFirstCompile }) => {
148140
if (!isFirstCompile) {
149141
return;
150142
}
151143

152-
for (const result of promisesResult) {
153-
if (result.status === 'error') {
154-
if (options.abortOnError) {
155-
throw new Error(result.errorMessage);
156-
}
157-
result.errorMessage && logger.error(result.errorMessage);
158-
logger.warn(
159-
'With the `abortOnError` configuration currently turned off, type errors do not cause build failures, but they do not guarantee proper type file output.',
160-
);
144+
promisesResult = await Promise.all(dtsPromises);
145+
},
146+
// Set the order to 'pre' to ensure that when DTS files of multiple formats are generated simultaneously,
147+
// all errors are thrown together before exiting the process.
148+
order: 'pre',
149+
});
150+
151+
api.onAfterBuild(({ isFirstCompile }) => {
152+
if (!isFirstCompile) {
153+
return;
154+
}
155+
156+
for (const result of promisesResult) {
157+
if (result.status === 'error') {
158+
if (options.abortOnError) {
159+
throw new Error(result.errorMessage);
161160
}
161+
result.errorMessage && logger.error(result.errorMessage);
162+
logger.warn(
163+
'With the `abortOnError` configuration currently turned off, type errors do not cause build failures, but they do not guarantee proper type file output.',
164+
);
162165
}
163-
},
164-
// Set the order to 'post' to ensure that when DTS files of multiple formats are generated
165-
// simultaneously, all errors are thrown together before exiting the process.
166-
order: 'post',
166+
}
167167
});
168168

169169
const killProcesses = () => {

0 commit comments

Comments
 (0)