From fe1ae6933998104c144b2c8854f362289c8d91c6 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:08:51 -0500 Subject: [PATCH] fix(@angular-devkit/architect): avoid Node.js resolution for relative builder schema To avoid the need to perform Node.js resolution for the typical case of a relative builder schema, a check is now performed to determine if a schema path within the build manifest appears to be relative. --- .../node/node-modules-architect-host.ts | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/angular_devkit/architect/node/node-modules-architect-host.ts b/packages/angular_devkit/architect/node/node-modules-architect-host.ts index c7ee4d85f576..feb90e803b4a 100644 --- a/packages/angular_devkit/architect/node/node-modules-architect-host.ts +++ b/packages/angular_devkit/architect/node/node-modules-architect-host.ts @@ -193,28 +193,22 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost "${builder.schema}"`, + `Package "${packageName}" has an invalid builder schema path: "${builderName}" --> "${builder.schema}"`, ); } // The file could be either a package reference or in the local manifest directory. - // Node resolution is tried first then reading the file from the manifest directory if resolution fails. - try { - schemaPath = localRequire.resolve(schemaPath, { - paths: [buildersManifestDirectory], - }); - } catch (e) { - if ((e as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') { - schemaPath = path.join(buildersManifestDirectory, schemaPath); - } else { - throw e; - } + if (schemaPath.startsWith('.')) { + schemaPath = path.join(buildersManifestDirectory, schemaPath); + } else { + const manifestRequire = createRequire(buildersManifestDirectory + '/'); + schemaPath = manifestRequire.resolve(schemaPath); } const schemaText = readFileSync(schemaPath, 'utf-8');