Skip to content

Commit 1626d50

Browse files
authored
perf: use promise to process dts files (#915)
1 parent b7c29fc commit 1626d50

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

packages/plugin-dts/src/utils.ts

+23-21
Original file line numberDiff line numberDiff line change
@@ -378,29 +378,31 @@ export async function processDtsFiles(
378378
absolute: true,
379379
});
380380

381-
for (const file of dtsFiles) {
382-
try {
383-
if (banner || footer) {
384-
await addBannerAndFooter(file, banner, footer);
385-
}
381+
await Promise.all(
382+
dtsFiles.map(async (file) => {
383+
try {
384+
if (banner || footer) {
385+
await addBannerAndFooter(file, banner, footer);
386+
}
386387

387-
if ((redirect.path || redirect.extension) && matchPath) {
388-
await redirectDtsImports(
389-
file,
390-
dtsExtension,
391-
redirect,
392-
matchPath,
393-
dir,
394-
rootDir,
395-
);
396-
}
388+
if ((redirect.path || redirect.extension) && matchPath) {
389+
await redirectDtsImports(
390+
file,
391+
dtsExtension,
392+
redirect,
393+
matchPath,
394+
dir,
395+
rootDir,
396+
);
397+
}
397398

398-
const newFile = file.replace('.d.ts', dtsExtension);
399-
fs.renameSync(file, newFile);
400-
} catch (error) {
401-
logger.error(`Failed to rename declaration file ${file}: ${error}`);
402-
}
403-
}
399+
const newFile = file.replace('.d.ts', dtsExtension);
400+
await fsP.rename(file, newFile);
401+
} catch (error) {
402+
logger.error(`Failed to rename declaration file ${file}: ${error}`);
403+
}
404+
}),
405+
);
404406
}
405407

406408
export function processSourceEntry(

0 commit comments

Comments
 (0)