@@ -93,32 +93,45 @@ export async function buildEsbuildBrowser(
9393 ) ,
9494 ) ;
9595
96- // Execute esbuild
97- const result = await bundleCode (
98- workspaceRoot ,
99- entryPoints ,
100- outputNames ,
101- options ,
102- optimizationOptions ,
103- sourcemapOptions ,
104- tsconfig ,
105- ) ;
96+ const [ codeResults , styleResults ] = await Promise . all ( [
97+ // Execute esbuild to bundle the application code
98+ bundleCode (
99+ workspaceRoot ,
100+ entryPoints ,
101+ outputNames ,
102+ options ,
103+ optimizationOptions ,
104+ sourcemapOptions ,
105+ tsconfig ,
106+ ) ,
107+ // Execute esbuild to bundle the global stylesheets
108+ bundleGlobalStylesheets (
109+ workspaceRoot ,
110+ outputNames ,
111+ options ,
112+ optimizationOptions ,
113+ sourcemapOptions ,
114+ ) ,
115+ ] ) ;
106116
107117 // Log all warnings and errors generated during bundling
108- await logMessages ( context , result ) ;
118+ await logMessages ( context , {
119+ errors : [ ...codeResults . errors , ...styleResults . errors ] ,
120+ warnings : [ ...codeResults . warnings , ...styleResults . warnings ] ,
121+ } ) ;
109122
110123 // Return if the bundling failed to generate output files or there are errors
111- if ( ! result . outputFiles || result . errors . length ) {
124+ if ( ! codeResults . outputFiles || codeResults . errors . length ) {
112125 return { success : false } ;
113126 }
114127
115- // Structure the bundling output files
128+ // Structure the code bundling output files
116129 const initialFiles : FileInfo [ ] = [ ] ;
117130 const outputFiles : OutputFile [ ] = [ ] ;
118- for ( const outputFile of result . outputFiles ) {
131+ for ( const outputFile of codeResults . outputFiles ) {
119132 // Entries in the metafile are relative to the `absWorkingDir` option which is set to the workspaceRoot
120133 const relativeFilePath = path . relative ( workspaceRoot , outputFile . path ) ;
121- const entryPoint = result . metafile ?. outputs [ relativeFilePath ] ?. entryPoint ;
134+ const entryPoint = codeResults . metafile ?. outputs [ relativeFilePath ] ?. entryPoint ;
122135
123136 outputFile . path = relativeFilePath ;
124137
@@ -133,6 +146,15 @@ export async function buildEsbuildBrowser(
133146 outputFiles . push ( outputFile ) ;
134147 }
135148
149+ // Add global stylesheets output files
150+ outputFiles . push ( ...styleResults . outputFiles ) ;
151+ initialFiles . push ( ...styleResults . initialFiles ) ;
152+
153+ // Return if the global stylesheet bundling has errors
154+ if ( styleResults . errors . length ) {
155+ return { success : false } ;
156+ }
157+
136158 // Create output directory if needed
137159 try {
138160 await fs . mkdir ( outputPath , { recursive : true } ) ;
@@ -143,25 +165,6 @@ export async function buildEsbuildBrowser(
143165 return { success : false } ;
144166 }
145167
146- // Process global stylesheets
147- const styleResults = await bundleGlobalStylesheets (
148- workspaceRoot ,
149- outputNames ,
150- options ,
151- optimizationOptions ,
152- sourcemapOptions ,
153- ) ;
154- outputFiles . push ( ...styleResults . outputFiles ) ;
155- initialFiles . push ( ...styleResults . initialFiles ) ;
156-
157- // Log all warnings and errors generated during bundling
158- await logMessages ( context , styleResults ) ;
159-
160- // Return if the bundling has errors
161- if ( styleResults . errors . length ) {
162- return { success : false } ;
163- }
164-
165168 // Generate index HTML file
166169 if ( options . index ) {
167170 const entrypoints = generateEntryPoints ( {
0 commit comments