@@ -57,7 +57,7 @@ export class ComponentStylesheetBundler {
57
57
} ) ;
58
58
} ) ;
59
59
60
- return extractResult ( await bundlerContext . bundle ( ) , bundlerContext . watchFiles ) ;
60
+ return this . extractResult ( await bundlerContext . bundle ( ) , bundlerContext . watchFiles ) ;
61
61
}
62
62
63
63
async bundleInline ( data : string , filename : string , language : string ) {
@@ -103,7 +103,7 @@ export class ComponentStylesheetBundler {
103
103
} ) ;
104
104
105
105
// Extract the result of the bundling from the output files
106
- return extractResult ( await bundlerContext . bundle ( ) , bundlerContext . watchFiles ) ;
106
+ return this . extractResult ( await bundlerContext . bundle ( ) , bundlerContext . watchFiles ) ;
107
107
}
108
108
109
109
invalidate ( files : Iterable < string > ) {
@@ -128,52 +128,50 @@ export class ComponentStylesheetBundler {
128
128
129
129
await Promise . allSettled ( contexts . map ( ( context ) => context . dispose ( ) ) ) ;
130
130
}
131
- }
132
131
133
- function extractResult ( result : BundleContextResult , referencedFiles ?: Set < string > ) {
134
- let contents = '' ;
135
- let map ;
136
- let outputPath ;
137
- const resourceFiles : OutputFile [ ] = [ ] ;
138
- if ( ! result . errors ) {
139
- for ( const outputFile of result . outputFiles ) {
140
- const filename = path . basename ( outputFile . path ) ;
141
- if ( outputFile . type === BuildOutputFileType . Media ) {
142
- // The output files could also contain resources (images/fonts/etc.) that were referenced
143
- resourceFiles . push ( outputFile ) ;
144
- } else if ( filename . endsWith ( '.css' ) ) {
145
- outputPath = outputFile . path ;
146
- contents = outputFile . text ;
147
- } else if ( filename . endsWith ( '.css.map' ) ) {
148
- map = outputFile . text ;
149
- } else {
150
- throw new Error (
151
- `Unexpected non CSS/Media file "${ filename } " outputted during component stylesheet processing.` ,
152
- ) ;
132
+ private extractResult ( result : BundleContextResult , referencedFiles ?: Set < string > ) {
133
+ let contents = '' ;
134
+ let metafile ;
135
+ const outputFiles : OutputFile [ ] = [ ] ;
136
+
137
+ if ( ! result . errors ) {
138
+ for ( const outputFile of result . outputFiles ) {
139
+ const filename = path . basename ( outputFile . path ) ;
140
+
141
+ // Needed for Bazel as otherwise the files will not be written in the correct place.
142
+ outputFile . path = path . join ( this . options . workspaceRoot , outputFile . path ) ;
143
+
144
+ if ( outputFile . type === BuildOutputFileType . Media ) {
145
+ // The output files could also contain resources (images/fonts/etc.) that were referenced
146
+ outputFiles . push ( outputFile ) ;
147
+ } else if ( filename . endsWith ( '.css' ) ) {
148
+ contents = outputFile . text ;
149
+ } else if ( filename . endsWith ( '.css.map' ) ) {
150
+ outputFiles . push ( outputFile ) ;
151
+ } else {
152
+ throw new Error (
153
+ `Unexpected non CSS/Media file "${ filename } " outputted during component stylesheet processing.` ,
154
+ ) ;
155
+ }
153
156
}
157
+
158
+ metafile = result . metafile ;
159
+ // Remove entryPoint fields from outputs to prevent the internal component styles from being
160
+ // treated as initial files. Also mark the entry as a component resource for stat reporting.
161
+ Object . values ( metafile . outputs ) . forEach ( ( output ) => {
162
+ delete output . entryPoint ;
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
+ ( output as any ) [ 'ng-component' ] = true ;
165
+ } ) ;
154
166
}
155
- }
156
167
157
- let metafile ;
158
- if ( ! result . errors ) {
159
- metafile = result . metafile ;
160
- // Remove entryPoint fields from outputs to prevent the internal component styles from being
161
- // treated as initial files. Also mark the entry as a component resource for stat reporting.
162
- Object . values ( metafile . outputs ) . forEach ( ( output ) => {
163
- delete output . entryPoint ;
164
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
- ( output as any ) [ 'ng-component' ] = true ;
166
- } ) ;
168
+ return {
169
+ errors : result . errors ,
170
+ warnings : result . warnings ,
171
+ contents,
172
+ outputFiles,
173
+ metafile,
174
+ referencedFiles,
175
+ } ;
167
176
}
168
-
169
- return {
170
- errors : result . errors ,
171
- warnings : result . warnings ,
172
- contents,
173
- map,
174
- path : outputPath ,
175
- resourceFiles,
176
- metafile,
177
- referencedFiles,
178
- } ;
179
177
}
0 commit comments