Skip to content

Commit

Permalink
Use named export for sync defaultResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Aug 31, 2021
1 parent 193ad83 commit 2203a7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/jest-resolve/src/__mocks__/userResolver.d.ts
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import defaultResolver from '../defaultResolver';
import {defaultResolver} from '../defaultResolver';

// todo: can be replaced with jest.MockedFunction
declare const userResolver: jest.MockInstance<
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-resolve/src/__tests__/resolve.test.ts
Expand Up @@ -12,7 +12,7 @@ import resolveAsync = require('resolve');
import {ModuleMap} from 'jest-haste-map';
import userResolver from '../__mocks__/userResolver';
import userResolverAsync from '../__mocks__/userResolverAsync';
import defaultResolver, {defaultResolverAsync} from '../defaultResolver';
import {defaultResolver, defaultResolverAsync} from '../defaultResolver';
import nodeModulesPaths from '../nodeModulesPaths';
import Resolver from '../resolver';
import type {ResolverConfig} from '../types';
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-resolve/src/defaultResolver.ts
Expand Up @@ -13,10 +13,10 @@ import {tryRealpath} from 'jest-util';
// QUESTION: What is a better way to import this?
const resolveAsync = require('resolve/lib/async');

type ResolverOptions = {
export type ResolverOptions = {
basedir: Config.Path;
browser?: boolean;
defaultResolver: typeof defaultResolverSync;
defaultResolver: typeof defaultResolver;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
Expand All @@ -37,7 +37,7 @@ declare global {
}
}

export default function defaultResolverSync(
export function defaultResolver(
path: Config.Path,
options: ResolverOptions,
): Config.Path {
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-resolve/src/resolver.ts
Expand Up @@ -14,8 +14,9 @@ import type {Config} from '@jest/types';
import type {IModuleMap} from 'jest-haste-map';
import {tryRealpath} from 'jest-util';
import ModuleNotFoundError from './ModuleNotFoundError';
import defaultResolver, {
import {
clearDefaultResolverCache,
defaultResolver,
defaultResolverAsync,
} from './defaultResolver';
import isBuiltinModule from './isBuiltinModule';
Expand Down

0 comments on commit 2203a7f

Please sign in to comment.