Skip to content

Commit 91543fa

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 be574a4 commit 91543fa

1 file changed

Lines changed: 1 addition & 16 deletions

File tree

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

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

Lines changed: 1 addition & 16 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,
@@ -127,7 +113,6 @@ export async function normalizeLibraryOptions(
127113
);
128114

129115
const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);
130-
131116
const styleIncludePaths = (stylePreprocessorOptions?.includePaths ?? []).map((p: string) =>
132117
path.resolve(workspaceRoot, p),
133118
);
@@ -143,7 +128,7 @@ export async function normalizeLibraryOptions(
143128
projectRoot,
144129
packageName,
145130
packageJson,
146-
outputPath: resolvedOutputPath,
131+
outputPath: path.resolve(workspaceRoot, options.outputPath ?? path.join('dist', projectName)),
147132
deleteOutputPath,
148133
packageJsonPath,
149134
tsConfigPath: resolvedTsConfigPath,

0 commit comments

Comments
 (0)