Skip to content

Commit

Permalink
use esmockResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
koshic committed Oct 14, 2023
1 parent b948324 commit 69b3343
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/esmockModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs'
import resolvewith from 'resolvewithplus'
import esmockErr from './esmockErr.js'
import esmockIsESMRe from './esmockIsESMRe.js'
import esmockResolver from './esmockResolver.js'

import {
esmockTreeIdSet,
Expand Down Expand Up @@ -116,7 +117,8 @@ const esmockModuleId = async (parent, treeid, defs, ids, opt, mocks, id) => {

if (!id) return mocks

const fileURL = opt.resolver(id, parent)
const resolver = await esmockResolver(opt)
const fileURL = resolver(id, parent)
if (!fileURL && opt.isModuleNotFoundError !== false && id !== 'import')
throw esmockErr.errModuleIdNotFound(id, parent)

Expand All @@ -126,7 +128,8 @@ const esmockModuleId = async (parent, treeid, defs, ids, opt, mocks, id) => {
}

const esmockModule = async (moduleId, parent, defs, gdefs, opt) => {
const moduleFileURL = opt.resolver(moduleId, parent)
const resolver = await esmockResolver(opt)
const moduleFileURL = resolver(moduleId, parent)
if (!moduleFileURL)
throw esmockErr.errModuleIdNotFound(moduleId, parent)

Expand Down
File renamed without changes.

0 comments on commit 69b3343

Please sign in to comment.