From eb95a073da663797f21a0c84901ef464b0d86efc Mon Sep 17 00:00:00 2001 From: Maxim Mazurok Date: Sat, 6 May 2023 19:07:42 +1000 Subject: [PATCH] use pathToFileURL --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index af58fed..8edc060 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const Module = require('module'); const {isAbsolute} = require('path'); +const { pathToFileURL } = require('url'); exports.dynamicImport = importEsm; exports.importEsm = importEsm; @@ -19,5 +20,5 @@ async function importEsm(specifier, module) { } catch { throw new Error(`Unable to locate module "${specifier}" relative to "${module?.filename}" using the CommonJS resolver. Consider passing an absolute path to the target module.`); } - return import(resolvedPath); + return import(pathToFileURL(resolvedPath).href); }