From e5ac0e82db2cd320de5da773fd0c495228029097 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 6 Feb 2022 20:18:02 -0500 Subject: [PATCH] fix --- src/configuration.ts | 2 +- src/util.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/configuration.ts b/src/configuration.ts index 5e2b9927c..176d92ee3 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -173,7 +173,7 @@ export function readConfig( if (options.require) { // Modules are found relative to the tsconfig file, not the `dir` option const tsconfigRelativeResolver = - createProjectLocalResolveHelper(configPath); + createProjectLocalResolveHelper(dirname(configPath)); options.require = options.require.map((path: string) => tsconfigRelativeResolver(path, false) ); diff --git a/src/util.ts b/src/util.ts index ca8536d8a..bc79d6f8e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -4,6 +4,7 @@ import { } from 'module'; import type _createRequire from 'create-require'; import * as ynModule from 'yn'; +import { dirname } from 'path'; /** @internal */ export const createRequire = @@ -149,5 +150,9 @@ export function getBasePathForProjectLocalDependencyResolution( projectOption: string | undefined, cwdOption: string ) { - return configFilePath ?? projectSearchDirOption ?? projectOption ?? cwdOption; + if(configFilePath != null) return dirname(configFilePath); + return projectSearchDirOption ?? projectOption ?? cwdOption; + // TODO technically breaks if projectOption is path to a file, not a directory, + // and we attempt to resolve relative specifiers. By the time we resolve relative specifiers, + // should have configFilePath, so not reach this codepath. }