From e98e9e0e2ded1600e1a82bc3cdf8156725128181 Mon Sep 17 00:00:00 2001 From: Alan Agius <alanagius@google.com> Date: Fri, 26 Jul 2024 08:55:24 +0000 Subject: [PATCH] fix(@angular/build): resolve error with `extract-i18n` builder for libraries The `extract-i18n` builder is only intended to be used with application projects. Closes #28109 --- .../build/src/builders/extract-i18n/builder.ts | 11 +++++++++++ .../src/builders/extract-i18n/builder.ts | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/angular/build/src/builders/extract-i18n/builder.ts b/packages/angular/build/src/builders/extract-i18n/builder.ts index ab4397c5d505..a63c469f0c4c 100644 --- a/packages/angular/build/src/builders/extract-i18n/builder.ts +++ b/packages/angular/build/src/builders/extract-i18n/builder.ts @@ -32,6 +32,17 @@ export async function execute( return { success: false }; } + const { projectType } = (await context.getProjectMetadata(projectName)) as { + projectType?: string; + }; + if (projectType !== 'application') { + context.logger.error( + `The 'extract-i18n' builder requires the project type to be an applivation .`, + ); + + return { success: false }; + } + // Check Angular version. assertCompatibleAngularVersion(context.workspaceRoot); diff --git a/packages/angular_devkit/build_angular/src/builders/extract-i18n/builder.ts b/packages/angular_devkit/build_angular/src/builders/extract-i18n/builder.ts index 81edd08febf0..b744cec32ee1 100644 --- a/packages/angular_devkit/build_angular/src/builders/extract-i18n/builder.ts +++ b/packages/angular_devkit/build_angular/src/builders/extract-i18n/builder.ts @@ -35,6 +35,17 @@ export async function execute( return { success: false }; } + const { projectType } = (await context.getProjectMetadata(projectName)) as { + projectType?: string; + }; + if (projectType !== 'application') { + context.logger.error( + `The 'extract-i18n' builder requires the project type to be an applivation .`, + ); + + return { success: false }; + } + // Check Angular version. assertCompatibleAngularVersion(context.workspaceRoot);