From 228a2edd4a6c9bd2e7e70f2e4f8564bda9d8e754 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 20 Sep 2018 11:28:29 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): fully resolve project modules --- .../utilities/require-project-module.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts index 18c3cc4cf036..ec1eed116dca 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/require-project-module.ts @@ -5,19 +5,18 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -// tslint:disable -// TODO: cleanup this file, it's copied as is from Angular CLI. -import * as fs from 'fs'; -import * as path from 'path'; +import { resolve } from '@angular-devkit/core/node'; // Resolve dependencies within the target project. export function resolveProjectModule(root: string, moduleName: string) { - const rootModules = path.join(root, 'node_modules'); - if (fs.existsSync(rootModules)) { - return require.resolve(moduleName, { paths: [rootModules] }); - } else { - return require.resolve(moduleName, { paths: [root] }); - } + return resolve( + moduleName, + { + basedir: root, + checkGlobal: false, + checkLocal: true, + }, + ); } // Require dependencies within the target project.