Skip to content

Commit 9f61796

Browse files
committed
Fix vite plugin adding/remove extra space loop for types file
1 parent d3510c8 commit 9f61796

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apps/array/vite-plugin-auto-services.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,24 @@ export function autoServicesPlugin(servicesDir: string): Plugin {
2222
const typeFiles = files.filter((f) => f.endsWith(".types.ts"));
2323

2424
// Generate index.ts (imports implementations for auto-registration)
25+
const serviceImports = serviceFiles
26+
.map((f) => `import "./${f.replace(".ts", ".js")}";`)
27+
.join("\n");
2528
const indexContent = `/**
2629
* Auto-register all IPC services
2730
* This file is auto-generated by vite-plugin-auto-services.ts
2831
*/
29-
30-
${serviceFiles.map((f) => `import "./${f.replace(".ts", ".js")}";`).join("\n")}
31-
`;
32+
${serviceImports ? `\n${serviceImports}\n` : ""}`;
3233

3334
// Generate types.ts (imports type files for declaration merging)
35+
const typeImports = typeFiles
36+
.map((f) => `import "./${f.replace(".ts", ".js")}";`)
37+
.join("\n");
3438
const typesContent = `/**
3539
* Auto-import all IPC service types for declaration merging
3640
* This file is auto-generated by vite-plugin-auto-services.ts
3741
*/
38-
39-
${typeFiles.map((f) => `import "./${f.replace(".ts", ".js")}";`).join("\n")}
40-
`;
42+
${typeImports ? `\n${typeImports}\n` : ""}`;
4143

4244
// Check if content actually changed before writing
4345
const indexPath = join(servicesDir, "index.ts");

0 commit comments

Comments
 (0)