@@ -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,51 @@ 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
+ const outputFiles : OutputFile [ ] = [ ] ;
135
+ if ( ! result . errors ) {
136
+ for ( const outputFile of result . outputFiles ) {
137
+ const filename = path . basename ( outputFile . path ) ;
138
+
139
+ // Needed for Bazel as otherwise the files will not be written in the correct place.
140
+ outputFile . path = path . join ( this . options . workspaceRoot , outputFile . path ) ;
141
+
142
+ if ( outputFile . type === BuildOutputFileType . Media ) {
143
+ // The output files could also contain resources (images/fonts/etc.) that were referenced
144
+ outputFiles . push ( outputFile ) ;
145
+ } else if ( filename . endsWith ( '.css' ) ) {
146
+ contents = outputFile . text ;
147
+ } else if ( filename . endsWith ( '.css.map' ) ) {
148
+ outputFiles . push ( outputFile ) ;
149
+ } else {
150
+ throw new Error (
151
+ `Unexpected non CSS/Media file "${ filename } " outputted during component stylesheet processing.` ,
152
+ ) ;
153
+ }
153
154
}
154
155
}
155
- }
156
156
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
- } ) ;
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
+ } ) ;
167
+ }
168
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
- } ;
169
+ return {
170
+ errors : result . errors ,
171
+ warnings : result . warnings ,
172
+ contents,
173
+ outputFiles,
174
+ metafile,
175
+ referencedFiles,
176
+ } ;
177
+ }
179
178
}
0 commit comments