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:
parent
10fdf3d23b
commit
8a551c1272
3 changed files with 12 additions and 0 deletions
5
.changeset/stupid-teachers-yell.md
Normal file
5
.changeset/stupid-teachers-yell.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Cleans up content layer sync during builds and programmatic `sync()` calls
|
|
@ -120,6 +120,7 @@ export async function createContainer({
|
|||
logger,
|
||||
skip: {
|
||||
content: true,
|
||||
cleanup: true,
|
||||
},
|
||||
force: inlineConfig?.force,
|
||||
manifest,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue