@@ -93,32 +93,45 @@ export async function buildEsbuildBrowser(
93
93
) ,
94
94
) ;
95
95
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
+ ] ) ;
106
116
107
117
// 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
+ } ) ;
109
122
110
123
// 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 ) {
112
125
return { success : false } ;
113
126
}
114
127
115
- // Structure the bundling output files
128
+ // Structure the code bundling output files
116
129
const initialFiles : FileInfo [ ] = [ ] ;
117
130
const outputFiles : OutputFile [ ] = [ ] ;
118
- for ( const outputFile of result . outputFiles ) {
131
+ for ( const outputFile of codeResults . outputFiles ) {
119
132
// Entries in the metafile are relative to the `absWorkingDir` option which is set to the workspaceRoot
120
133
const relativeFilePath = path . relative ( workspaceRoot , outputFile . path ) ;
121
- const entryPoint = result . metafile ?. outputs [ relativeFilePath ] ?. entryPoint ;
134
+ const entryPoint = codeResults . metafile ?. outputs [ relativeFilePath ] ?. entryPoint ;
122
135
123
136
outputFile . path = relativeFilePath ;
124
137
@@ -133,6 +146,15 @@ export async function buildEsbuildBrowser(
133
146
outputFiles . push ( outputFile ) ;
134
147
}
135
148
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
+
136
158
// Create output directory if needed
137
159
try {
138
160
await fs . mkdir ( outputPath , { recursive : true } ) ;
@@ -143,25 +165,6 @@ export async function buildEsbuildBrowser(
143
165
return { success : false } ;
144
166
}
145
167
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
-
165
168
// Generate index HTML file
166
169
if ( options . index ) {
167
170
const entrypoints = generateEntryPoints ( {
0 commit comments