diff --git a/src/esmockModule.js b/src/esmockModule.js index 3adc68d..7ab4524 100644 --- a/src/esmockModule.js +++ b/src/esmockModule.js @@ -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, @@ -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) @@ -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) diff --git a/src/esmockReslover.js b/src/esmockResolver.js similarity index 100% rename from src/esmockReslover.js rename to src/esmockResolver.js