@@ -17,7 +17,6 @@ import { strings } from '@angular-devkit/core';
1717import type { ConfigOptions } from 'karma' ;
1818import { createRequire } from 'node:module' ;
1919import * as path from 'node:path' ;
20- import { Observable , from , mergeMap } from 'rxjs' ;
2120import { Configuration } from 'webpack' ;
2221import { ExecutionTransformer } from '../../transforms' ;
2322import { normalizeFileReplacements } from '../../utils' ;
@@ -31,45 +30,43 @@ export type KarmaConfigOptions = ConfigOptions & {
3130/**
3231 * @experimental Direct usage of this function is considered experimental.
3332 */
34- export function execute (
33+ export async function * execute (
3534 options : KarmaBuilderOptions ,
3635 context : BuilderContext ,
3736 transforms : {
3837 webpackConfiguration ?: ExecutionTransformer < Configuration > ;
3938 // The karma options transform cannot be async without a refactor of the builder implementation
4039 karmaOptions ?: ( options : KarmaConfigOptions ) => KarmaConfigOptions ;
4140 } = { } ,
42- ) : Observable < BuilderOutput > {
41+ ) : AsyncIterable < BuilderOutput > {
4342 // Check Angular version.
4443 assertCompatibleAngularVersion ( context . workspaceRoot ) ;
4544
46- return from ( getExecuteWithBuilder ( options , context ) ) . pipe (
47- mergeMap ( ( [ useEsbuild , executeWithBuilder ] ) => {
48- if ( useEsbuild ) {
49- if ( transforms . webpackConfiguration ) {
50- context . logger . warn (
51- `This build is using the application builder but transforms.webpackConfiguration was provided. The transform will be ignored.` ,
52- ) ;
53- }
54-
55- if ( options . fileReplacements ) {
56- options . fileReplacements = normalizeFileReplacements ( options . fileReplacements , './' ) ;
57- }
58-
59- if ( typeof options . polyfills === 'string' ) {
60- options . polyfills = [ options . polyfills ] ;
61- }
62-
63- // eslint-disable-next-line @typescript-eslint/no-explicit-any
64- return executeWithBuilder ( options as any , context , transforms ) ;
65- } else {
66- const karmaOptions = getBaseKarmaOptions ( options , context ) ;
67-
68- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69- return executeWithBuilder ( options as any , context , karmaOptions , transforms ) ;
70- }
71- } ) ,
72- ) ;
45+ const [ useEsbuild , executeWithBuilder ] = await getExecuteWithBuilder ( options , context ) ;
46+
47+ if ( useEsbuild ) {
48+ if ( transforms . webpackConfiguration ) {
49+ context . logger . warn (
50+ `This build is using the application builder but transforms.webpackConfiguration was provided. The transform will be ignored.` ,
51+ ) ;
52+ }
53+
54+ if ( options . fileReplacements ) {
55+ options . fileReplacements = normalizeFileReplacements ( options . fileReplacements , './' ) ;
56+ }
57+
58+ if ( typeof options . polyfills === 'string' ) {
59+ options . polyfills = [ options . polyfills ] ;
60+ }
61+
62+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63+ yield * executeWithBuilder ( options as any , context , transforms ) ;
64+ } else {
65+ const karmaOptions = getBaseKarmaOptions ( options , context ) ;
66+
67+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68+ yield * executeWithBuilder ( options as any , context , karmaOptions , transforms ) ;
69+ }
7370}
7471
7572function getBaseKarmaOptions (
@@ -169,7 +166,7 @@ function getBuiltInKarmaConfig(
169166}
170167
171168export type { KarmaBuilderOptions } ;
172- export default createBuilder < Record < string , string > & KarmaBuilderOptions > ( execute ) ;
169+ export default createBuilder < KarmaBuilderOptions > ( execute ) ;
173170
174171async function getExecuteWithBuilder (
175172 options : KarmaBuilderOptions ,
0 commit comments