Skip to content

Commit 4244eb7

Browse files
committed
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.
1 parent 88ebc67 commit 4244eb7

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

  • packages/angular/build/src/builders/library

‎packages/angular/build/src/builders/library/options.ts‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { normalizeAssetPatterns } from '../../utils';
1414
import { supportColor } from '../../utils/color';
1515
import { assertIsError } from '../../utils/error';
1616
import { normalizeCacheOptions } from '../../utils/normalize-cache';
17-
import { isSubDirectory } from '../../utils/path';
1817
import {
1918
generateSearchDirectories,
2019
getTailwindConfig,
@@ -34,19 +33,6 @@ export async function normalizeLibraryOptions(
3433
const projectMetadata = await context.getProjectMetadata(projectName);
3534
const { projectRoot, projectSourceRoot } = getProjectRootPaths(workspaceRoot, projectMetadata);
3635

37-
const outputPath = options.outputPath ?? path.join(workspaceRoot, 'dist', projectName);
38-
const resolvedOutputPath = path.resolve(workspaceRoot, outputPath);
39-
if (
40-
resolvedOutputPath === projectRoot ||
41-
isSubDirectory(resolvedOutputPath, projectRoot) ||
42-
isSubDirectory(projectRoot, resolvedOutputPath)
43-
) {
44-
throw new Error(
45-
`The 'outputPath' (${resolvedOutputPath}) cannot be the project root, ` +
46-
`contain the project root, or be located within the project root.`,
47-
);
48-
}
49-
5036
const {
5137
tsConfig,
5238
assets: rawAssets,
@@ -143,7 +129,7 @@ export async function normalizeLibraryOptions(
143129
projectRoot,
144130
packageName,
145131
packageJson,
146-
outputPath: resolvedOutputPath,
132+
outputPath: path.resolve(workspaceRoot, options.outputPath ?? path.join('dist', projectName)),
147133
deleteOutputPath,
148134
packageJsonPath,
149135
tsConfigPath: resolvedTsConfigPath,

0 commit comments

Comments
 (0)