Skip to content

Commit

Permalink
Merge pull request #442 from relative-ci/fix-vite-asset-circular-refe…
Browse files Browse the repository at this point in the history
…rence

fix: Transform - prevent circular chunk dependencies
  • Loading branch information
vio authored Jan 22, 2025
2 parents bfd10b2 + 5bce489 commit 710c33f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,17 @@ export const bundleToWebpackStats = (
// Collect metadata
entries.forEach((entry) => {
if (entry.type === 'chunk') {
entry.imports?.forEach((chunkDependency) => {
if (!chunksIssuers[chunkDependency]) {
chunksIssuers[chunkDependency] = [];
entry.imports?.forEach((chunkImportFileName) => {
// Skip circular references
if (chunksIssuers[entry.fileName]?.find((chunkIssuer) => chunkIssuer.fileName === chunkImportFileName)) {
return;
}

chunksIssuers[chunkDependency].push(entry);
if (!chunksIssuers[chunkImportFileName]) {
chunksIssuers[chunkImportFileName] = [];
}

chunksIssuers[chunkImportFileName].push(entry);
});
}
});
Expand Down

0 comments on commit 710c33f

Please sign in to comment.