From 4b4bdb248bd27ceffd10d40d70e3dbcc54b7b3b8 Mon Sep 17 00:00:00 2001 From: ahaoboy <504595380@qq.com> Date: Fri, 28 Feb 2025 17:22:47 +0800 Subject: [PATCH] support empty imports --- src/analyze/warnings.ts | 2 +- src/analyze/whyfile.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/analyze/warnings.ts b/src/analyze/warnings.ts index 498110c..d69e42c 100644 --- a/src/analyze/warnings.ts +++ b/src/analyze/warnings.ts @@ -17,7 +17,7 @@ let generateWarnings = (metafile: Metafile): HTMLElement[] => { for (let i in inputs) { let input = inputs[i] - for (let record of input.imports) { + for (let record of input.imports || []) { if (record.original && record.original[0] !== '.') { let array = resolvedPaths[record.original] || (resolvedPaths[record.original] = []) if (!array.includes(record.path)) array.push(record.path) diff --git a/src/analyze/whyfile.ts b/src/analyze/whyfile.ts index c2d8b00..2391029 100644 --- a/src/analyze/whyfile.ts +++ b/src/analyze/whyfile.ts @@ -59,7 +59,7 @@ export let computeImporters = (metafile: Metafile): Info => { if (entryPoint) { entryPoints[entryPoint] = o allEntryPointOutputs.push(o) - for (let record of output.imports) { + for (let record of output.imports || []) { if (!record.external && !hasOwnProperty.call(crossChunkImports, record.path)) { crossChunkImports[record.path] = true } @@ -98,7 +98,7 @@ export let computeImporters = (metafile: Metafile): Info => { for (let path of current) { let input = inputs[path] - for (let record of input.imports) { + for (let record of input.imports || []) { if (!record.external && !hasOwnProperty.call(importers, record.path)) { importers[record.path] = { inputPath_: path,