Skip to content

Commit

Permalink
fix: ignore imports of non-existing modules (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Dec 10, 2023
1 parent 1da4dbe commit c43ba2b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bundle-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ export async function parseBundleInfo(bundleAsts: Record<string, SWC.Module>): P

// Add reverse edges for dependency graph traversal
moduleInfo.imported.forEach(importedModuleName => {
bundleInfo[importedModuleName].importedBy.push(moduleName);
if (bundleInfo[importedModuleName]) {
bundleInfo[importedModuleName].importedBy.push(moduleName);
} else {
console.warn(
`[vite-plugin-top-level-await] Non-existing module ${JSON.stringify(
importedModuleName
)} imported by ${JSON.stringify(moduleName)}, ignoring.`
);
}
});

const highestPattern = findHighestPattern(ast);
Expand Down

0 comments on commit c43ba2b

Please sign in to comment.