Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions packages/angular/build/src/builders/library/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.`,
);
}

Comment on lines -37 to -49

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should keep this safety check but remove isSubDirectory(projectRoot, resolvedOutputPath) and update the error message to cannot be the project root or contain the project root.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would break the usage in case it’s a single project repo, and the dist is in the project root.

I can add the check that is not the project root in a follow up, so that this check is also added in the application builder.

@clydin clydin Oct 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist in the project root would be fine. Its the case where the project root is inside the output path itself that is problematic since that would delete the entire project root on a build.

const {
tsConfig,
assets: rawAssets,
Expand Down Expand Up @@ -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,
Expand Down
Loading