From ca38ee34c6267e32b8ee74db815f929896f1baba Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 26 Oct 2023 07:17:47 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): avoid binary content in architect results with browser-esbuild The builder system (architect) currently attempts to treat all results as JSON and attempts to validate the object with a JSON schema validator. This can lead to slow build completion (even after the actual build is fully complete) or crashes if the size and/or quantity of output files is large. Architect only requires a `success` property so that is all that will be passed here if the infrastructure settings have not been explicitly set to avoid writes. Writing is only disabled when used directly by the dev server which bypasses the architect behavior. (cherry picked from commit cdea51865a997c2717cb71b48b9fe4e05634b854) --- .../src/builders/browser-esbuild/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts index cb17074048b7..577a6d9f8691 100644 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts @@ -57,7 +57,16 @@ export async function* buildEsbuildBrowser( await writeResultFiles(result.outputFiles, result.assetFiles, fullOutputPath); } - yield result; + // The builder system (architect) currently attempts to treat all results as JSON and + // attempts to validate the object with a JSON schema validator. This can lead to slow + // build completion (even after the actual build is fully complete) or crashes if the + // size and/or quantity of output files is large. Architect only requires a `success` + // property so that is all that will be passed here if the infrastructure settings have + // not been explicitly set to avoid writes. Writing is only disabled when used directly + // by the dev server which bypasses the architect behavior. + const builderResult = + infrastructureSettings?.write === false ? result : { success: result.success }; + yield builderResult; } }