88import fs from 'fs-extra' ;
99import path from 'path' ;
1010import _ from 'lodash' ;
11- import { compile } from '@docusaurus/bundler' ;
11+ import { compile , registerBundlerTracing } from '@docusaurus/bundler' ;
1212import logger , { PerfLogger } from '@docusaurus/logger' ;
1313import { loadSite } from '../../server/site' ;
1414import { handleBrokenLinks } from '../../server/brokenLinks' ;
@@ -35,6 +35,7 @@ export type BuildLocaleParams = {
3535} ;
3636
3737const SkipBundling = process . env . DOCUSAURUS_SKIP_BUNDLING === 'true' ;
38+ const ExitAfterBundling = process . env . DOCUSAURUS_EXIT_AFTER_BUNDLING === 'true' ;
3839
3940export async function buildLocale ( {
4041 siteDir,
@@ -93,6 +94,9 @@ export async function buildLocale({
9394 `Skipping the Docusaurus bundling step because DOCUSAURUS_SKIP_BUNDLING='true'` ,
9495 ) ;
9596 } else {
97+ const cleanupBundlerTracing = await registerBundlerTracing ( {
98+ currentBundler : props . currentBundler ,
99+ } ) ;
96100 // Run webpack to build JS bundle (client) and static html files (server).
97101 await PerfLogger . async ( `Bundling with ${ props . currentBundler . name } ` , ( ) => {
98102 return compile ( {
@@ -102,6 +106,10 @@ export async function buildLocale({
102106 currentBundler : configureWebpackUtils . currentBundler ,
103107 } ) ;
104108 } ) ;
109+ await cleanupBundlerTracing ( ) ;
110+ }
111+ if ( ExitAfterBundling ) {
112+ return process . exit ( 0 ) ;
105113 }
106114
107115 const { collectedData} = await PerfLogger . async ( 'SSG' , ( ) =>
0 commit comments