Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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