From 49ed9a26cb87ae629d7d4167277f7e5c4ee066f7 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 22 Dec 2023 13:57:17 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): emit error when using prerender and app-shell builders with application builder The application builder has built-in prerendering and app-shell generation capabilities which makes using these builders redundant. --- .../build_angular/src/builders/app-shell/index.ts | 10 ++++++++++ .../build_angular/src/builders/prerender/index.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts b/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts index cee1d7659bcf..436fef59d3ee 100644 --- a/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts @@ -178,6 +178,16 @@ async function _appShellBuilder( serviceWorker: false, optimization: optimization as unknown as JsonObject, }); + + if (browserTargetRun.info.builderName === '@angular-devkit/build-angular:application') { + return { + success: false, + error: + '"@angular-devkit/build-angular:application" has built-in app-shell generation capabilities. ' + + 'The "appShell" option should be used instead.', + }; + } + const serverTargetRun = await context.scheduleTarget(serverTarget, { watch: false, }); diff --git a/packages/angular_devkit/build_angular/src/builders/prerender/index.ts b/packages/angular_devkit/build_angular/src/builders/prerender/index.ts index deba6c67e5e1..16def499835e 100644 --- a/packages/angular_devkit/build_angular/src/builders/prerender/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/prerender/index.ts @@ -106,6 +106,16 @@ async function _scheduleBuilds( serviceWorker: false, // todo: handle service worker augmentation }); + + if (browserTargetRun.info.builderName === '@angular-devkit/build-angular:application') { + return { + success: false, + error: + '"@angular-devkit/build-angular:application" has built-in prerendering capabilities. ' + + 'The "prerender" option should be used instead.', + }; + } + const serverTargetRun = await context.scheduleTarget(serverTarget, { watch: false, });