Skip to content

Commit ddd08ef

Browse files
committedMay 2, 2024·
fix(@angular-devkit/architect): resolve builder aliases from containing package
When resolving a builder alias, the base path for the resolution will now use the containing package. This prevents potential resolution failure due to varying package manager installation strategies. (cherry picked from commit 57d57b4)
1 parent 80fa030 commit ddd08ef

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎packages/angular_devkit/architect/node/node-modules-architect-host.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
126126
* @param builderStr The name of the builder to be used.
127127
* @returns All the info needed for the builder itself.
128128
*/
129-
resolveBuilder(builderStr: string, seenBuilders?: Set<string>): Promise<NodeModulesBuilderInfo> {
129+
resolveBuilder(
130+
builderStr: string,
131+
basePath = this._root,
132+
seenBuilders?: Set<string>,
133+
): Promise<NodeModulesBuilderInfo> {
130134
if (seenBuilders?.has(builderStr)) {
131135
throw new Error(
132136
'Circular builder alias references detected: ' + [...seenBuilders, builderStr],
@@ -140,7 +144,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
140144

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

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

171175
// Resolve alias reference if entry is a string
172176
if (typeof builder === 'string') {
173-
return this.resolveBuilder(builder, (seenBuilders ?? new Set()).add(builderStr));
177+
return this.resolveBuilder(
178+
builder,
179+
path.dirname(packageJsonPath),
180+
(seenBuilders ?? new Set()).add(builderStr),
181+
);
174182
}
175183

176184
// Determine builder implementation path (relative within package only)

0 commit comments

Comments
 (0)
Please sign in to comment.