From 8d6198020a5ec775b0dbaf7e08924f4bdcc677f8 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 12 Aug 2023 19:44:33 -0500 Subject: [PATCH] fix: Only check file dependencies once/file. (#901) Fixes #900 --- src/plugin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 52f8f42d1..e70b15318 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -22,17 +22,18 @@ async function main() { if (options.emitImportedFiles) { const fileSet = new Set(); - const addFilesUnlessAliased = (filenames: string[]) => { + function addFilesUnlessAliased(filenames: string[]) { filenames .filter((name) => !options.M[name]) .forEach((name) => { + if (fileSet.has(name)) return; fileSet.add(name); const file = request.protoFile.find((file) => file.name === name); if (file && file.dependency.length > 0) { addFilesUnlessAliased(file.dependency); } }); - }; + } addFilesUnlessAliased(request.fileToGenerate); filesToGenerate = request.protoFile.filter((file) => fileSet.has(file.name)); } else {