Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular-devkit/architect): resolve builder aliases from containing package #27575

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
* @param builderStr The name of the builder to be used.
* @returns All the info needed for the builder itself.
*/
resolveBuilder(builderStr: string, seenBuilders?: Set<string>): Promise<NodeModulesBuilderInfo> {
resolveBuilder(
builderStr: string,
basePath = this._root,
seenBuilders?: Set<string>,
): Promise<NodeModulesBuilderInfo> {
if (seenBuilders?.has(builderStr)) {
throw new Error(
'Circular builder alias references detected: ' + [...seenBuilders, builderStr],
Expand All @@ -140,7 +144,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu

// Resolve and load the builders manifest from the package's `builders` field, if present
const packageJsonPath = localRequire.resolve(packageName + '/package.json', {
paths: [this._root],
paths: [basePath],
});

const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { builders?: string };
Expand Down Expand Up @@ -170,7 +174,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu

// Resolve alias reference if entry is a string
if (typeof builder === 'string') {
return this.resolveBuilder(builder, (seenBuilders ?? new Set()).add(builderStr));
return this.resolveBuilder(
builder,
path.dirname(packageJsonPath),
(seenBuilders ?? new Set()).add(builderStr),
);
}

// Determine builder implementation path (relative within package only)
Expand Down