Skip to content

Commit

Permalink
refactor(@angular/build): add helper types to internal HTML rewriter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin committed Oct 18, 2024
1 parent 1654acf commit 0b5e5c4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RewritingStream['emitStartTag']>[0];
export type EndTag = Parameters<RewritingStream['emitEndTag']>[0];
export type { RewritingStream };

export async function htmlRewritingStream(content: string): Promise<{
rewriter: import('parse5-html-rewriting-stream').RewritingStream;
rewriter: RewritingStream;
transformedContent: () => Promise<string>;
}> {
const { RewritingStream } = await loadEsmModule<typeof import('parse5-html-rewriting-stream')>(
Expand Down

0 comments on commit 0b5e5c4

Please sign in to comment.