Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Feb 7, 2022
1 parent d96591e commit e5ac0e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down
7 changes: 6 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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.
}

0 comments on commit e5ac0e8

Please sign in to comment.