From 3b8ec7cc1f60db3ceb558124e242d7bf0ed20c06 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Fri, 18 Oct 2024 09:32:40 -0400 Subject: [PATCH] refactor(@angular/build): add helper types to internal HTML rewriter The `StartTag` and `EndTag` types are now also exported along with the `htmlRewritingStream` factory. These types are commonly used with the rewriter and by exporting them reduces the need to manually extract them from the underlying methods. --- .../build/src/utils/index-file/html-rewriting-stream.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/angular/build/src/utils/index-file/html-rewriting-stream.ts b/packages/angular/build/src/utils/index-file/html-rewriting-stream.ts index 5ae7c397904d..dbeeadcb2fc1 100644 --- a/packages/angular/build/src/utils/index-file/html-rewriting-stream.ts +++ b/packages/angular/build/src/utils/index-file/html-rewriting-stream.ts @@ -8,10 +8,16 @@ import { Readable } from 'node:stream'; import { pipeline } from 'node:stream/promises'; +import type { RewritingStream } from 'parse5-html-rewriting-stream'; import { loadEsmModule } from '../load-esm'; +// Export helper types for the rewriter +export type StartTag = Parameters[0]; +export type EndTag = Parameters[0]; +export type { RewritingStream }; + export async function htmlRewritingStream(content: string): Promise<{ - rewriter: import('parse5-html-rewriting-stream').RewritingStream; + rewriter: RewritingStream; transformedContent: () => Promise; }> { const { RewritingStream } = await loadEsmModule(