Skip to content

Commit 824e912

Browse files
committed
chore: update
1 parent 760e59d commit 824e912

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

packages/plugin-dts/src/tsgo.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { spawn } from 'node:child_process';
2-
import fs from 'node:fs';
2+
import fsP from 'node:fs/promises';
33
import { createRequire } from 'node:module';
44
import path from 'node:path';
55
import { logger } from '@rsbuild/core';
66
import color from 'picocolors';
7-
import ts from 'typescript';
7+
import type ts from 'typescript';
88
import type { DtsRedirect } from './index';
99
import type { EmitDtsOptions } from './tsc';
1010
import {
@@ -84,7 +84,7 @@ async function handleDiagnosticsAndProcessFiles(
8484
]);
8585
await Promise.all(
8686
dtsFiles.map(async (file) => {
87-
const contents = ts.sys.readFile(file) ?? '';
87+
const contents = await fsP.readFile(file, 'utf8');
8888
const newFileName = renameDtsFile(file, dtsExtension, bundle);
8989
const newContents = updateDeclarationMapContent(
9090
file,
@@ -94,12 +94,8 @@ async function handleDiagnosticsAndProcessFiles(
9494
tsConfigResult.options.declarationMap,
9595
);
9696
if (file !== newFileName || contents !== newContents) {
97-
ts.sys.writeFile(newFileName, newContents);
98-
if (ts.sys.deleteFile) {
99-
ts.sys.deleteFile(file);
100-
} else {
101-
fs.unlinkSync(file);
102-
}
97+
await fsP.writeFile(newFileName, newContents);
98+
await fsP.unlink(file);
10399
}
104100
}),
105101
);

0 commit comments

Comments
 (0)