Skip to content

Commit acbc66f

Browse files
authored
fix: fix config import breaking on windows (#995)
1 parent c06d427 commit acbc66f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/helpers/import-helper.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const url = require('url');
2+
13
async function supportsDynamicImport() {
24
try {
35
// imports are cached.
@@ -20,8 +22,13 @@ async function supportsDynamicImport() {
2022
async function importModule(modulePath) {
2123
// JSON modules are still behind a flag. Fallback to require for now.
2224
// https://nodejs.org/api/esm.html#json-modules
23-
if (!modulePath.endsWith('.json') && (await supportsDynamicImport())) {
24-
return import(modulePath);
25+
if (
26+
url.pathToFileURL &&
27+
!modulePath.endsWith('.json') &&
28+
(await supportsDynamicImport())
29+
) {
30+
// 'import' expects a URL. (https://github.com/sequelize/cli/issues/994)
31+
return import(url.pathToFileURL(modulePath));
2532
}
2633

2734
// mimics what `import()` would return for

0 commit comments

Comments
 (0)