Skip to content

Commit 361382a

Browse files
committed
build: add return types for component stylesheet bundler
(cherry picked from commit bc43f95)
1 parent 47d9d3b commit 361382a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/angular/build/src/tools/esbuild/angular/component-stylesheets.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import {
2121
createStylesheetBundleOptions,
2222
} from '../stylesheets/bundle-options';
2323

24+
export type ComponentStylesheetResult = BundleContextResult & {
25+
contents: string;
26+
referencedFiles: Set<string> | undefined;
27+
};
28+
2429
/**
2530
* Bundles component stylesheets. A stylesheet can be either an inline stylesheet that
2631
* is contained within the Component's metadata definition or an external file referenced
@@ -48,7 +53,11 @@ export class ComponentStylesheetBundler {
4853
* @param direct If true, the output will be used directly by the builder; false if used inside the compiler plugin.
4954
* @returns A component bundle result object.
5055
*/
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> {
5261
const bundlerContext = await this.#fileContexts.getOrCreate(entry, () => {
5362
return new BundlerContext(this.options.workspaceRoot, this.incremental, (loadCache) => {
5463
const buildOptions = createStylesheetBundleOptions(this.options, loadCache);
@@ -82,7 +91,7 @@ export class ComponentStylesheetBundler {
8291
filename: string,
8392
language = this.defaultInlineLanguage,
8493
externalId?: string,
85-
) {
94+
): Promise<ComponentStylesheetResult> {
8695
// Use a hash of the inline stylesheet content to ensure a consistent identifier. External stylesheets will resolve
8796
// to the actual stylesheet file path.
8897
// TODO: Consider xxhash instead for hashing
@@ -191,13 +200,13 @@ export class ComponentStylesheetBundler {
191200
referencedFiles: Set<string> | undefined,
192201
external: boolean,
193202
direct: boolean,
194-
) {
203+
): ComponentStylesheetResult {
195204
let contents = '';
196205
const outputFiles: BuildOutputFile[] = [];
197206

198207
const { errors, warnings } = result;
199208
if (errors) {
200-
return { errors, warnings, referencedFiles };
209+
return { errors, warnings, referencedFiles, contents: '' };
201210
}
202211

203212
for (const outputFile of result.outputFiles) {

0 commit comments

Comments
 (0)