@@ -201,50 +201,11 @@ export async function compileLibrary(
201201}
202202
203203/**
204- * Formats stylesheet bundling diagnostics and TypeScript/Angular diagnostics
205- * and records them on the build state's execution result.
206- *
207- * @param compilationInstance The active Angular compilation instance.
208- * @param stylesheetErrors List of stylesheet bundling errors.
209- * @param stylesheetWarnings List of stylesheet bundling warnings.
210- * @param colors Whether diagnostic messages should be formatted with ANSI colors.
211- * @param buildState The build state whose execution result receives the formatted diagnostics.
204+ * Updates cached in-memory ESM and DTS maps with newly emitted files and prunes deleted files.
212205 */
213- async function runDiagnosticsAndFormat (
214- compilationInstance : AngularCompilation ,
215- stylesheetErrors : PartialMessage [ ] ,
216- stylesheetWarnings : PartialMessage [ ] ,
217- colors : boolean ,
218- buildState : BuilderState ,
219- ) : Promise < void > {
220- const { executionResult } = buildState ;
221- const errors = [ ...stylesheetErrors ] ;
222- const warnings : PartialMessage [ ] = [ ] ;
223-
224- if ( errors . length === 0 && useTypeChecking ) {
225- const diagnostics = await compilationInstance . diagnoseFiles ( ) ;
226- if ( diagnostics . errors ?. length ) {
227- errors . push ( ...diagnostics . errors ) ;
228- }
229- if ( diagnostics . warnings ?. length ) {
230- warnings . push ( ...diagnostics . warnings ) ;
231- }
232- }
233-
234- warnings . push ( ...stylesheetWarnings ) ;
235-
236- if ( errors . length > 0 ) {
237- executionResult . addErrors ( await formatMessages ( errors , { kind : 'error' , color : colors } ) ) ;
238- }
239-
240- if ( warnings . length > 0 ) {
241- executionResult . addWarnings ( await formatMessages ( warnings , { kind : 'warning' , color : colors } ) ) ;
242- }
243- }
244-
245206function updateEmittedFileMaps (
246207 emittedFiles : Iterable < { filename : string ; contents : string } > ,
247- cached : BuilderState [ singleProgramCache ] ,
208+ cached : BuilderState [ ' singleProgramCache' ] ,
248209 posixReferencedFiles : ReadonlySet < string > ,
249210 effectiveModifiedFiles : ReadonlySet < string > | undefined ,
250211 hasCompilationModeChanged : boolean ,
@@ -262,7 +223,7 @@ function updateEmittedFileMaps(
262223 dtsFiles . clear ( ) ;
263224 } else if ( removeDtsMaps ) {
264225 for ( const key of dtsFiles . keys ( ) ) {
265- if ( key . endsWith ( . map ) ) {
226+ if ( key . endsWith ( ' .map' ) ) {
266227 dtsFiles . delete ( key ) ;
267228 }
268229 }
@@ -277,7 +238,7 @@ function updateEmittedFileMaps(
277238 continue ;
278239 }
279240
280- const basePathWithoutExt = modifiedFile . replace ( / (?: \. d \. [ c m ] ? t s | \. [ c m ] ? [ j t ] s x ? ) $ / i, ) ;
241+ const basePathWithoutExt = modifiedFile . replace ( / (?: \. d \. [ c m ] ? t s | \. [ c m ] ? [ j t ] s x ? ) $ / i, '' ) ;
281242 if ( basePathWithoutExt === modifiedFile || existsSync ( modifiedFile ) ) {
282243 continue ;
283244 }
@@ -299,17 +260,57 @@ function updateEmittedFileMaps(
299260
300261 for ( const { filename, contents } of emittedFiles ) {
301262 const normalized = toPosixPath ( filename ) ;
302- const isMap = normalized . endsWith ( . map ) ;
263+ const isMap = normalized . endsWith ( ' .map' ) ;
303264 const isDts = isMap ? isDeclarationSourceMapFile ( normalized ) : isDeclarationFile ( normalized ) ;
304265 const targetFiles = isDts ? dtsFiles : esmFiles ;
305266
306267 if ( targetFiles . get ( normalized ) !== contents ) {
307268 targetFiles . set ( normalized , contents ) ;
308- ( isDts ? changedDtsFiles : changedEsmFiles ) . add (
309- isMap ? normalized . slice ( 0 , - 4 ) : normalized ,
310- ) ;
269+ ( isDts ? changedDtsFiles : changedEsmFiles ) . add ( isMap ? normalized . slice ( 0 , - 4 ) : normalized ) ;
311270 }
312271 }
313272
314273 return { esmFiles, dtsFiles, changedEsmFiles, changedDtsFiles } ;
315274}
275+
276+ /**
277+ * Formats stylesheet bundling diagnostics and TypeScript/Angular diagnostics
278+ * and records them on the build state's execution result.
279+ *
280+ * @param compilationInstance The active Angular compilation instance.
281+ * @param stylesheetErrors List of stylesheet bundling errors.
282+ * @param stylesheetWarnings List of stylesheet bundling warnings.
283+ * @param colors Whether diagnostic messages should be formatted with ANSI colors.
284+ * @param buildState The build state whose execution result receives the formatted diagnostics.
285+ */
286+ async function runDiagnosticsAndFormat (
287+ compilationInstance : AngularCompilation ,
288+ stylesheetErrors : PartialMessage [ ] ,
289+ stylesheetWarnings : PartialMessage [ ] ,
290+ colors : boolean ,
291+ buildState : BuilderState ,
292+ ) : Promise < void > {
293+ const { executionResult } = buildState ;
294+ const errors = [ ...stylesheetErrors ] ;
295+ const warnings : PartialMessage [ ] = [ ] ;
296+
297+ if ( errors . length === 0 && useTypeChecking ) {
298+ const diagnostics = await compilationInstance . diagnoseFiles ( ) ;
299+ if ( diagnostics . errors ?. length ) {
300+ errors . push ( ...diagnostics . errors ) ;
301+ }
302+ if ( diagnostics . warnings ?. length ) {
303+ warnings . push ( ...diagnostics . warnings ) ;
304+ }
305+ }
306+
307+ warnings . push ( ...stylesheetWarnings ) ;
308+
309+ if ( errors . length > 0 ) {
310+ executionResult . addErrors ( await formatMessages ( errors , { kind : 'error' , color : colors } ) ) ;
311+ }
312+
313+ if ( warnings . length > 0 ) {
314+ executionResult . addWarnings ( await formatMessages ( warnings , { kind : 'warning' , color : colors } ) ) ;
315+ }
316+ }
0 commit comments