Skip to content

Commit

Permalink
Stop traversing the graph when you encounter a propagated asset
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed May 25, 2023
1 parent cdf1706 commit f85033b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/astro/src/core/render/dev/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export async function* crawlGraph(
const entryIsStyle = isCSSRequest(id);

for (const importedModule of entry.importedModules) {
// A propagation stopping point is a module with the ?astroPropagatedAssets flag.
// When we encounter one of these modules we don't want to continue traversing.
let isPropagationStoppingPoint = false;
// some dynamically imported modules are *not* server rendered in time
// to only SSR modules that we can safely transform, we check against
// a list of file extensions based on our built-in vite plugins
Expand All @@ -63,10 +66,11 @@ export async function* crawlGraph(
const isFileTypeNeedingSSR = fileExtensionsToSSR.has(
npath.extname(importedModulePathname)
);
isPropagationStoppingPoint = ASTRO_PROPAGATED_ASSET_REGEX.test(importedModule.id);
if (
isFileTypeNeedingSSR &&
// Should not SSR a module with ?astroPropagatedAssets
!ASTRO_PROPAGATED_ASSET_REGEX.test(importedModule.id)
!isPropagationStoppingPoint
) {
const mod = loader.getModuleById(importedModule.id);
if (!mod?.ssrModule) {
Expand All @@ -78,7 +82,9 @@ export async function* crawlGraph(
}
}
}
importedModules.add(importedModule);
if(!isPropagationStoppingPoint) {
importedModules.add(importedModule);
}
}
}
}
Expand Down

0 comments on commit f85033b

Please sign in to comment.