Skip to content
Merged
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/fix-lookup-map-oom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes performance regression and OOM errors when building medium-sized blogs with many content entries. Replaced O(n²) object spread pattern with direct mutation in `generateLookupMap`.
18 changes: 4 additions & 14 deletions packages/astro/src/content/vite-plugin-content-virtual-mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,22 +355,12 @@ async function generateLookupMap({ settings, fs }: { settings: AstroSettings; fs
: undefined,
});
}
lookupMap[collection] = {
type: 'content',
entries: {
...lookupMap[collection]?.entries,
[slug]: rootRelativePath(root, filePath),
},
};
lookupMap[collection] ??= { type: 'content', entries: {} };
lookupMap[collection].entries[slug] = rootRelativePath(root, filePath);
} else {
const id = getDataEntryId({ entry: pathToFileURL(filePath), contentDir, collection });
lookupMap[collection] = {
type: 'data',
entries: {
...lookupMap[collection]?.entries,
[id]: rootRelativePath(root, filePath),
},
};
lookupMap[collection] ??= { type: 'data', entries: {} };
lookupMap[collection].entries[id] = rootRelativePath(root, filePath);
}
}),
);
Expand Down
Loading