Skip to content

Commit 0b5e5c4

Browse files
committed
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.
1 parent 1654acf commit 0b5e5c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/angular/build/src/utils/index-file/html-rewriting-stream.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88

99
import { Readable } from 'node:stream';
1010
import { pipeline } from 'node:stream/promises';
11+
import type { RewritingStream } from 'parse5-html-rewriting-stream';
1112
import { loadEsmModule } from '../load-esm';
1213

14+
// Export helper types for the rewriter
15+
export type StartTag = Parameters<RewritingStream['emitStartTag']>[0];
16+
export type EndTag = Parameters<RewritingStream['emitEndTag']>[0];
17+
export type { RewritingStream };
18+
1319
export async function htmlRewritingStream(content: string): Promise<{
14-
rewriter: import('parse5-html-rewriting-stream').RewritingStream;
20+
rewriter: RewritingStream;
1521
transformedContent: () => Promise<string>;
1622
}> {
1723
const { RewritingStream } = await loadEsmModule<typeof import('parse5-html-rewriting-stream')>(

0 commit comments

Comments
 (0)