@@ -11,7 +11,7 @@ import { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/plat
11
11
import * as fs from 'node:fs' ;
12
12
import { dirname , join , normalize , resolve } from 'node:path' ;
13
13
import { URL } from 'node:url' ;
14
- import { InlineCriticalCssProcessor , InlineCriticalCssResult } from './inline-css-processor' ;
14
+ import { CommonEngineInlineCriticalCssProcessor } from './inline-css-processor' ;
15
15
import {
16
16
noopRunMethodAndMeasurePerf ,
17
17
printPerformanceLogs ,
@@ -55,14 +55,10 @@ export interface CommonEngineRenderOptions {
55
55
56
56
export class CommonEngine {
57
57
private readonly templateCache = new Map < string , string > ( ) ;
58
- private readonly inlineCriticalCssProcessor : InlineCriticalCssProcessor ;
58
+ private readonly inlineCriticalCssProcessor = new CommonEngineInlineCriticalCssProcessor ( ) ;
59
59
private readonly pageIsSSG = new Map < string , boolean > ( ) ;
60
60
61
- constructor ( private options ?: CommonEngineOptions ) {
62
- this . inlineCriticalCssProcessor = new InlineCriticalCssProcessor ( {
63
- minify : false ,
64
- } ) ;
65
- }
61
+ constructor ( private options ?: CommonEngineOptions ) { }
66
62
67
63
/**
68
64
* Render an HTML document for a specific URL with specified
@@ -81,17 +77,12 @@ export class CommonEngine {
81
77
html = await runMethod ( 'Render Page' , ( ) => this . renderApplication ( opts ) ) ;
82
78
83
79
if ( opts . inlineCriticalCss !== false ) {
84
- const { content, errors , warnings } = await runMethod ( 'Inline Critical CSS' , ( ) =>
80
+ const content = await runMethod ( 'Inline Critical CSS' , ( ) =>
85
81
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86
82
this . inlineCriticalCss ( html ! , opts ) ,
87
83
) ;
88
84
89
85
html = content ;
90
-
91
- // eslint-disable-next-line no-console
92
- warnings ?. forEach ( ( m ) => console . warn ( m ) ) ;
93
- // eslint-disable-next-line no-console
94
- errors ?. forEach ( ( m ) => console . error ( m ) ) ;
95
86
}
96
87
}
97
88
@@ -102,13 +93,11 @@ export class CommonEngine {
102
93
return html ;
103
94
}
104
95
105
- private inlineCriticalCss (
106
- html : string ,
107
- opts : CommonEngineRenderOptions ,
108
- ) : Promise < InlineCriticalCssResult > {
109
- return this . inlineCriticalCssProcessor . process ( html , {
110
- outputPath : opts . publicPath ?? ( opts . documentFilePath ? dirname ( opts . documentFilePath ) : '' ) ,
111
- } ) ;
96
+ private inlineCriticalCss ( html : string , opts : CommonEngineRenderOptions ) : Promise < string > {
97
+ const outputPath =
98
+ opts . publicPath ?? ( opts . documentFilePath ? dirname ( opts . documentFilePath ) : '' ) ;
99
+
100
+ return this . inlineCriticalCssProcessor . process ( html , outputPath ) ;
112
101
}
113
102
114
103
private async retrieveSSGPage ( opts : CommonEngineRenderOptions ) : Promise < string | undefined > {
0 commit comments