@@ -21,6 +21,11 @@ import {
21
21
createStylesheetBundleOptions ,
22
22
} from '../stylesheets/bundle-options' ;
23
23
24
+ export type ComponentStylesheetResult = BundleContextResult & {
25
+ contents : string ;
26
+ referencedFiles : Set < string > | undefined ;
27
+ } ;
28
+
24
29
/**
25
30
* Bundles component stylesheets. A stylesheet can be either an inline stylesheet that
26
31
* is contained within the Component's metadata definition or an external file referenced
@@ -48,7 +53,11 @@ export class ComponentStylesheetBundler {
48
53
* @param direct If true, the output will be used directly by the builder; false if used inside the compiler plugin.
49
54
* @returns A component bundle result object.
50
55
*/
51
- async bundleFile ( entry : string , externalId ?: string | boolean , direct ?: boolean ) {
56
+ async bundleFile (
57
+ entry : string ,
58
+ externalId ?: string | boolean ,
59
+ direct ?: boolean ,
60
+ ) : Promise < ComponentStylesheetResult > {
52
61
const bundlerContext = await this . #fileContexts. getOrCreate ( entry , ( ) => {
53
62
return new BundlerContext ( this . options . workspaceRoot , this . incremental , ( loadCache ) => {
54
63
const buildOptions = createStylesheetBundleOptions ( this . options , loadCache ) ;
@@ -82,7 +91,7 @@ export class ComponentStylesheetBundler {
82
91
filename : string ,
83
92
language = this . defaultInlineLanguage ,
84
93
externalId ?: string ,
85
- ) {
94
+ ) : Promise < ComponentStylesheetResult > {
86
95
// Use a hash of the inline stylesheet content to ensure a consistent identifier. External stylesheets will resolve
87
96
// to the actual stylesheet file path.
88
97
// TODO: Consider xxhash instead for hashing
@@ -191,13 +200,13 @@ export class ComponentStylesheetBundler {
191
200
referencedFiles : Set < string > | undefined ,
192
201
external : boolean ,
193
202
direct : boolean ,
194
- ) {
203
+ ) : ComponentStylesheetResult {
195
204
let contents = '' ;
196
205
const outputFiles : BuildOutputFile [ ] = [ ] ;
197
206
198
207
const { errors, warnings } = result ;
199
208
if ( errors ) {
200
- return { errors, warnings, referencedFiles } ;
209
+ return { errors, warnings, referencedFiles, contents : '' } ;
201
210
}
202
211
203
212
for ( const outputFile of result . outputFiles ) {
0 commit comments