File tree Expand file tree Collapse file tree 2 files changed +25
-17
lines changed Expand file tree Collapse file tree 2 files changed +25
-17
lines changed Original file line number Diff line number Diff line change @@ -1612,6 +1612,7 @@ export async function createBuilder(
16121612 if ( useLegacyBuilder ) {
16131613 await setupEnvironment ( config . build . ssr ? 'ssr' : 'client' , config )
16141614 } else {
1615+ const environmentConfigs : [ string , ResolvedConfig ] [ ] = [ ]
16151616 for ( const environmentName of Object . keys ( config . environments ) ) {
16161617 // We need to resolve the config again so we can properly merge options
16171618 // and get a new set of plugins for each build environment. The ecosystem
@@ -1654,9 +1655,14 @@ export async function createBuilder(
16541655 patchPlugins ,
16551656 )
16561657 }
1657-
1658- await setupEnvironment ( environmentName , environmentConfig )
1658+ environmentConfigs . push ( [ environmentName , environmentConfig ] )
16591659 }
1660+ await Promise . all (
1661+ environmentConfigs . map (
1662+ async ( [ environmentName , environmentConfig ] ) =>
1663+ await setupEnvironment ( environmentName , environmentConfig ) ,
1664+ ) ,
1665+ )
16601666 }
16611667
16621668 return builder
Original file line number Diff line number Diff line change @@ -509,22 +509,24 @@ export async function _createServer(
509509
510510 const environments : Record < string , DevEnvironment > = { }
511511
512- for ( const [ name , environmentOptions ] of Object . entries (
513- config . environments ,
514- ) ) {
515- environments [ name ] = await environmentOptions . dev . createEnvironment (
516- name ,
517- config ,
518- {
519- ws,
520- } ,
521- )
522- }
512+ await Promise . all (
513+ Object . entries ( config . environments ) . map (
514+ async ( [ name , environmentOptions ] ) => {
515+ const environment = await environmentOptions . dev . createEnvironment (
516+ name ,
517+ config ,
518+ {
519+ ws,
520+ } ,
521+ )
522+ environments [ name ] = environment
523523
524- for ( const environment of Object . values ( environments ) ) {
525- const previousInstance = options . previousEnvironments ?. [ environment . name ]
526- await environment . init ( { watcher, previousInstance } )
527- }
524+ const previousInstance =
525+ options . previousEnvironments ?. [ environment . name ]
526+ await environment . init ( { watcher, previousInstance } )
527+ } ,
528+ ) ,
529+ )
528530
529531 // Backward compatibility
530532
You can’t perform that action at this time.
0 commit comments