Skip to content

Commit e5ac0e8

Browse files
committed
fix
1 parent d96591e commit e5ac0e8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export function readConfig(
173173
if (options.require) {
174174
// Modules are found relative to the tsconfig file, not the `dir` option
175175
const tsconfigRelativeResolver =
176-
createProjectLocalResolveHelper(configPath);
176+
createProjectLocalResolveHelper(dirname(configPath));
177177
options.require = options.require.map((path: string) =>
178178
tsconfigRelativeResolver(path, false)
179179
);

src/util.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
} from 'module';
55
import type _createRequire from 'create-require';
66
import * as ynModule from 'yn';
7+
import { dirname } from 'path';
78

89
/** @internal */
910
export const createRequire =
@@ -149,5 +150,9 @@ export function getBasePathForProjectLocalDependencyResolution(
149150
projectOption: string | undefined,
150151
cwdOption: string
151152
) {
152-
return configFilePath ?? projectSearchDirOption ?? projectOption ?? cwdOption;
153+
if(configFilePath != null) return dirname(configFilePath);
154+
return projectSearchDirOption ?? projectOption ?? cwdOption;
155+
// TODO technically breaks if projectOption is path to a file, not a directory,
156+
// and we attempt to resolve relative specifiers. By the time we resolve relative specifiers,
157+
// should have configFilePath, so not reach this codepath.
153158
}

0 commit comments

Comments
 (0)