From c205801e0a6afb741d431fea8de3bfe1c85cd1fe Mon Sep 17 00:00:00 2001 From: ephys Date: Sat, 15 Jan 2022 12:04:45 +0100 Subject: [PATCH] fix: fix config import breaking on windows --- src/helpers/import-helper.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/helpers/import-helper.js b/src/helpers/import-helper.js index 516ce9a2..bd5dcf62 100644 --- a/src/helpers/import-helper.js +++ b/src/helpers/import-helper.js @@ -1,3 +1,5 @@ +const url = require('url'); + async function supportsDynamicImport() { try { // imports are cached. @@ -20,8 +22,13 @@ async function supportsDynamicImport() { async function importModule(modulePath) { // JSON modules are still behind a flag. Fallback to require for now. // https://nodejs.org/api/esm.html#json-modules - if (!modulePath.endsWith('.json') && (await supportsDynamicImport())) { - return import(modulePath); + if ( + url.pathToFileURL && + !modulePath.endsWith('.json') && + (await supportsDynamicImport()) + ) { + // 'import' expects a URL. (https://github.com/sequelize/cli/issues/994) + return import(url.pathToFileURL(modulePath)); } // mimics what `import()` would return for