@@ -17,7 +17,10 @@ interface OptimizeDepsPatch {
1717 optimizeDeps ?: { noDiscovery ?: boolean ; include ?: string [ ] ; exclude ?: string [ ] } ;
1818}
1919
20- async function runConfigSetup ( command : 'dev' | 'build' | 'sync' ) {
20+ async function runConfigSetup (
21+ command : 'dev' | 'build' | 'sync' ,
22+ loggerConfig ?: { entrypoint : string } ,
23+ ) {
2124 const integration = cloudflare ( ) ;
2225 let updatedConfig : { vite : { plugins : unknown [ ] } } | undefined ;
2326
@@ -31,6 +34,7 @@ async function runConfigSetup(command: 'dev' | 'build' | 'sync') {
3134 experimental : { } ,
3235 vite : { } ,
3336 image : { } ,
37+ logger : loggerConfig ,
3438 } ,
3539 updateConfig ( config : { vite : { plugins : unknown [ ] } } ) {
3640 updatedConfig = config ;
@@ -116,5 +120,21 @@ describe('type generation phase (build and sync)', () => {
116120 assert . ok ( include . includes ( 'astro/actions/runtime/entrypoints/server.js' ) ) ;
117121 assert . ok ( include . includes ( 'astro/actions/runtime/entrypoints/route.js' ) ) ;
118122 } ) ;
123+
124+ it ( 'only prebundles the JSON logger when it is enabled' , async ( ) => {
125+ const defaultConfig = await runConfigSetup ( 'dev' ) ;
126+ const defaultInclude =
127+ defaultConfig . configEnvironment ( 'ssr' , { } ) ?. optimizeDeps ?. include ?? [ ] ;
128+ assert . ok ( ! defaultInclude . includes ( 'astro/logger/json' ) ) ;
129+
130+ const consoleConfig = await runConfigSetup ( 'dev' , { entrypoint : 'astro/logger/console' } ) ;
131+ const consoleInclude =
132+ consoleConfig . configEnvironment ( 'ssr' , { } ) ?. optimizeDeps ?. include ?? [ ] ;
133+ assert . ok ( ! consoleInclude . includes ( 'astro/logger/json' ) ) ;
134+
135+ const jsonConfig = await runConfigSetup ( 'dev' , { entrypoint : 'astro/logger/json' } ) ;
136+ const jsonInclude = jsonConfig . configEnvironment ( 'ssr' , { } ) ?. optimizeDeps ?. include ?? [ ] ;
137+ assert . ok ( jsonInclude . includes ( 'astro/logger/json' ) ) ;
138+ } ) ;
119139 } ) ;
120140} ) ;
0 commit comments