Skip to content

Commit

Permalink
fix: fix config import breaking on windows (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys authored Jan 15, 2022
1 parent c06d427 commit acbc66f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/helpers/import-helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const url = require('url');

async function supportsDynamicImport() {
try {
// imports are cached.
Expand All @@ -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
Expand Down

0 comments on commit acbc66f

Please sign in to comment.