From 3a27ae0757085cfc0ff95ab0d959d0a7e64ad390 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 19 May 2026 15:55:53 +0900 Subject: [PATCH] fix: false positive not exists error if sourceCode is empty (#17434) * fix: false positive not exists error if sourceCode is empty * Return empty array for empty sourceCode * lint --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --- packages/frontend-builder/locale-inliner.ts | 2 +- .../frontend-builder/locale-inliner/collect-modifications.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend-builder/locale-inliner.ts b/packages/frontend-builder/locale-inliner.ts index 1dc344e2a3..8d0d6e3d20 100644 --- a/packages/frontend-builder/locale-inliner.ts +++ b/packages/frontend-builder/locale-inliner.ts @@ -80,7 +80,7 @@ export class LocaleInliner { await fs.mkdir(path.join(this.outputDir, localeName), { recursive: true }); const localeLogger = localeName === 'ja-JP' ? this.logger : blankLogger; // we want to log for single locale only for (const chunk of this.chunks) { - if (!chunk.sourceCode || !chunk.modifications) { + if (chunk.sourceCode == null || !chunk.modifications) { throw new Error(`Source code or modifications for ${chunk.fileName} is not available.`); } const fileLogger = localeLogger.prefixed(`${chunk.fileName} (${chunk.chunkName}): `); diff --git a/packages/frontend-builder/locale-inliner/collect-modifications.ts b/packages/frontend-builder/locale-inliner/collect-modifications.ts index 2e92a407c9..80ce268f95 100644 --- a/packages/frontend-builder/locale-inliner/collect-modifications.ts +++ b/packages/frontend-builder/locale-inliner/collect-modifications.ts @@ -18,6 +18,7 @@ interface WalkerContext { } export function collectModifications(sourceCode: string, fileName: string, fileLogger: Logger, inliner: LocaleInliner): TextModification[] { + if (sourceCode === '') return []; let programNode: RolldownESTree.Program; try { programNode = parseAst(sourceCode);