Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Vite 4.3 module graph changes #6716

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/selfish-adults-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Handle Vite 4.3 module graph changes
4 changes: 4 additions & 0 deletions packages/astro/src/core/module-loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export interface ModuleNode {
ssrModule: Record<string, any> | null;
ssrError: Error | null;
importedModules: Set<ModuleNode>;
// Since Vite 4.3, `importedModules` strictly contains client-side imported modules only.
// For SSR, we need to use `ssrImportedModules` or `ssrTransformResult.deps` instead.
// The former is more ergonomic so we use it here.
ssrImportedModules?: Set<ModuleNode>;
}

export interface ModuleInfo {
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/core/render/dev/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export async function* crawlGraph(
if (id === entry.id) {
scanned.add(id);
const entryIsStyle = isCSSRequest(id);
for (const importedModule of entry.importedModules) {
const entryImportedModules = entry.ssrImportedModules ?? entry.importedModules;
for (const importedModule of entryImportedModules) {
// 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 Down