Skip to content

Commit

Permalink
Instrument more of the build
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Jul 10, 2024
1 parent c7c68a8 commit c5cc647
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class AstroBuilder {
/** Setup Vite and run any async setup logic that couldn't run inside of the constructor. */
private async setup() {
this.logger.debug('build', 'Initial setup...');
this.settings.timer.start('Init');
const { logger } = this;
this.timer.init = performance.now();
this.settings = await runHookConfigSetup({
Expand Down Expand Up @@ -150,18 +151,22 @@ class AstroBuilder {
return process.exit(syncRet);
}

const dataStore = await DataStore.fromModule();
globalDataStore.set(dataStore);
await syncContentLayer({ settings: this.settings, logger: logger });

this.settings.timer.end('Init');
return { viteConfig };
}

/** Run the build logic. build() is marked private because usage should go through ".run()" */
private async build({ viteConfig }: { viteConfig: vite.InlineConfig }) {
this.settings.timer.start('Build');

await runHookBuildStart({ config: this.settings.config, logging: this.logger });
this.validateConfig();

const dataStore = await DataStore.fromModule();
globalDataStore.set(dataStore);
this.settings.timer.start('Sync content layer');
await syncContentLayer({ settings: this.settings, logger: this.logger });
this.settings.timer.end('Sync content layer');
this.logger.info('build', `output: ${blue('"' + this.settings.config.output + '"')}`);
this.logger.info('build', `directory: ${blue(fileURLToPath(this.settings.config.outDir))}`);
if (this.settings.adapter) {
Expand Down Expand Up @@ -233,7 +238,7 @@ class AstroBuilder {
buildMode: this.settings.config.output,
});
}

this.settings.timer.end('Build');
// Benchmark results
this.settings.timer.writeStats();
}
Expand Down

0 comments on commit c5cc647

Please sign in to comment.