Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: fix config import breaking on windows #995

Merged
merged 1 commit into from
Jan 15, 2022
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