From 2b50db0f372095f44e0889d38f0546671a9fd5ef Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 2 Oct 2026 08:30:19 +0000 Subject: [PATCH] fix(@angular/build): allow library outputPath within project root Remove the upfront check restricting `outputPath` from being within or containing the project root in the library builder. This is needed for Bazel builds where the output directory (`bazel-out/...`) is located under the workspace/project root, and matches the behavior of the application builder which relies on `deleteOutputDir` when cleaning. --- .../build/src/builders/library/options.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/angular/build/src/builders/library/options.ts b/packages/angular/build/src/builders/library/options.ts index fdf5354f7fa7..b83f73ad23a8 100644 --- a/packages/angular/build/src/builders/library/options.ts +++ b/packages/angular/build/src/builders/library/options.ts @@ -14,7 +14,6 @@ import { normalizeAssetPatterns } from '../../utils'; import { supportColor } from '../../utils/color'; import { assertIsError } from '../../utils/error'; import { normalizeCacheOptions } from '../../utils/normalize-cache'; -import { isSubDirectory } from '../../utils/path'; import { generateSearchDirectories, getTailwindConfig, @@ -34,19 +33,6 @@ export async function normalizeLibraryOptions( const projectMetadata = await context.getProjectMetadata(projectName); const { projectRoot, projectSourceRoot } = getProjectRootPaths(workspaceRoot, projectMetadata); - const outputPath = options.outputPath ?? path.join(workspaceRoot, 'dist', projectName); - const resolvedOutputPath = path.resolve(workspaceRoot, outputPath); - if ( - resolvedOutputPath === projectRoot || - isSubDirectory(resolvedOutputPath, projectRoot) || - isSubDirectory(projectRoot, resolvedOutputPath) - ) { - throw new Error( - `The 'outputPath' (${resolvedOutputPath}) cannot be the project root, ` + - `contain the project root, or be located within the project root.`, - ); - } - const { tsConfig, assets: rawAssets, @@ -143,7 +129,7 @@ export async function normalizeLibraryOptions( projectRoot, packageName, packageJson, - outputPath: resolvedOutputPath, + outputPath: path.resolve(workspaceRoot, options.outputPath ?? path.join('dist', projectName)), deleteOutputPath, packageJsonPath, tsConfigPath: resolvedTsConfigPath,