0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Clean up content layer sync in build and sync api (#12633)

This commit is contained in:
Bjorn Lu 2024-12-05 18:13:36 +08:00 committed by GitHub
parent 10fdf3d23b
commit 8a551c1272
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Cleans up content layer sync during builds and programmatic `sync()` calls

View file

@ -120,6 +120,7 @@ export async function createContainer({
logger,
skip: {
content: true,
cleanup: true,
},
force: inlineConfig?.force,
manifest,

View file

@ -45,6 +45,8 @@ export type SyncOptions = {
skip?: {
// Must be skipped in dev
content?: boolean;
// Cleanup can be skipped in dev as some state can be reused on updates
cleanup?: boolean;
};
manifest: ManifestData;
};
@ -141,6 +143,10 @@ export async function syncInternal({
store,
});
await contentLayer.sync();
if (!skip?.cleanup) {
// Free up memory (usually in builds since we only need to use this once)
contentLayer.dispose();
}
settings.timer.end('Sync content layer');
} else {
const paths = getContentPaths(settings.config, fs);